NODE.JS常用命令

node 空格 某个js文件 # 调用 node 程序,运行某个js文件

node i express -g

==========================

var express = require('express')

var app = express();

app.get("/", function (req, res) {

复制代码
res.send('hello world')

});

app.listen(80, () => {

复制代码
console.log('web server running at http://127.0.0.1');

})

  1. clear 或者 cls # 清空界面

  2. ls/dir # 查看列表(list)

  3. cd 目录名 # 进入到目录中去

  4. cd ... # 返回上一级目录

  5. cd \ # 直接回到根目录

  6. Ctrl+C # 停止 Node 程序

  7. 输入部分文件名后按下 Tab 键 // 补全文件名 或 目录名, 多次tab会进行切换

  8. ↑ ↓ 上下箭头 # 切换历史输入

  9. npm info 包名 #搜索包

  10. npm install/i <包名>@版本号 #安装指定版本的包

  11. npm install/i 包名 #安装包 (安装到当前目录)

  12. npm list 包名 #查看包的版本信息

  13. npm uninstall 包名 #卸载包

  14. npm ls #查看包的列表

  15. npm init -y #初始化(会生成一个packagejson的文件,项目的配置信息)

  16. npm install/i <包> -g #全局安装(-g代表全局安装,不会在package.json中看到)

  17. npm config get registry #检查当前的下包地址

  18. npm config set registry=https://registry.npm.taobao.org/ 把下包的地址切换为国内的淘宝服务器

20.npm config set registry https://registry.npmjs.org 把下包的地址切换为国外服务器

21.npm config set prefix "全局module_global"

22.npm config set cache "全局module_cache"

=======================================

  1. node:启动 Node.js REPL(交互式解释器)

  2. node -v:查看 Node.js 版本号

  3. node -h:查看 Node.js 帮助文档

  4. node -p:执行 JavaScript 表达式并打印结果

  5. node -e:执行 JavaScript 代码片段

  6. node --inspect:启动 Node.js 调试器

  7. node --inspect-brk:在第一行暂停并启动 Node.js 调试器

  8. node --version:查看 Node.js 版本号

  9. node --help:查看 Node.js 帮助文档

  10. npm:Node.js 包管理器

  11. npm init:初始化一个新的 Node.js 项目

  12. npm install:安装 Node.js 模块

  13. npm uninstall:卸载 Node.js 模块

  14. npm update:更新 Node.js 模块

  15. npm search:搜索 Node.js 模块

  16. npm ls:列出当前项目中安装的 Node.js 模块

  17. npm run:运行 package.json 中定义的脚本

  18. npm start:启动 Node.js 项目

  19. npm test:运行 Node.js 项目的测试

  20. npm publish:发布 Node.js 模块到 npmjs.com

  21. npm help:查看 npm 帮助文档

  22. npm version:查看当前项目的版本号

  23. npm view:查看指定 Node.js 模块的信息

  24. npm outdated:查看当前项目中过时的 Node.js 模块

  25. npm audit:检查当前项目中的安全漏洞

  26. npm login:登录到 npmjs.com

  27. npm logout:退出 npmjs.com

  28. npm adduser:添加一个新的 npmjs.com 用户

  29. npm whoami:查看当前登录的 npmjs.com 用户名

  30. npm config:配置 npm

  31. npm cache:管理 npm 缓存

  32. npm doctor:检查当前环境是否符合 Node.js 和 npm 的要求

  33. npm rebuild:重新编译当前项目中的 Node.js 模块

  34. npm prune:删除当前项目中未使用的 Node.js 模块

  35. npm shrinkwrap:锁定当前项目中的 Node.js 模块版本号

  36. npm ci:安装当前项目中的 Node.js 模块,忽略 package.json 中的 devDependencies

  37. npm fund:查看当前项目中使用的 Node.js 模块的资助商信息

  38. npm init -y:快速初始化一个新的 Node.js 项目,使用默认配置

相关推荐
lzp07911 小时前
如何在Windows系统上安装和配置Node.js及Node版本管理器(nvm)
windows·node.js
weiwx834 小时前
【前端】Node.js使用教程
前端·node.js·vim
i建模5 小时前
Ubuntu Node.js 升级方案
linux·运维·ubuntu·node.js
结网的兔子7 小时前
前端学习笔记(实战准备篇)——用vite构建一个项目【吐血整理】
前端·学习·elementui·npm·node.js·vue
i建模7 小时前
npm国内镜像源加速
前端·npm·node.js
热爱生活的五柒21 小时前
解决 npm install 一直在转圈的问题
前端·npm·node.js
跟着珅聪学java1 天前
Electron 中实现“字符串转图片”功能教程
node.js
tryCbest1 天前
Git与Node.js安装及常用命令详解
git·node.js
_DoubleL1 天前
Volta启动项目自动切换Node版本
前端·node.js
小杨勇敢飞1 天前
npm 安装 @openai/codex 后无法调用 codex 命令的完整解决过程:‘codex‘ 不是内部或外部命令,也不是可运行的程序或批处理文件。
前端·npm·node.js