安装NVM: node 多版本管理工具
-
Mac|Linux: https://github.com/nvm-sh/nvm
-
Windows: https://github.com/coreybutler/nvm-windows/releases
-
下载node:
nvm install node
安装NRM: 配置安装源,加快安装下载速度
-
安装:
npm install nrm -g
-
内置源
PS D:\demo> nrm ls * npm -------- https://registry.npmjs.org/ yarn ------- https://registry.yarnpkg.com/ cnpm ------- http://r.cnpmjs.org/ taobao ----- https://registry.npm.taobao.org/ nj --------- https://registry.nodejitsu.com/ npmMirror -- https://skimdb.npmjs.com/registry/ edunpm ----- http://registry.enpmjs.org/
-
命令
nrm -h
-
使用淘宝镜像:
nrm use taobao
安装淘宝npm(cnpm)
npm install -g cnpm
cnpm -v
安装nodemon: 避免重复启动服务
-
安装:
npm i -g nodemon
或npm install -global nodemon
-
校验:
nodemon -v
-
启动命令:
nodemon src/app.js
配置package.json 后启动命令npm start
{ "name": "demo", "version": "1.0.0", "description": "", "main": "index.js", "scripts": { "start": "node src/app.js", "start-dev": "nodemon src/app.js", "test": "echo \"Error: no test specified\" && exit 1" }, "keywords": [], "author": "", "license": "ISC" }
-
配置nodemon监听文件范围
- nodemon.json
{ "watch": ["./src/**/*.*"] //只监听src下文件 }
网友评论