node.js 路由

安装 nodemon(自动重启) 与 cross-env (兼容不容平台)

npm install nodemon cross-env --save-dev 
--registry=https://registry.npm.taobao.org

package.json文件

 
{
  "name": "lianxi",
  "version": "1.0.0",
  "description": "",
  "main": "bin/www.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "dev":"cross-env NODE_ENV=dev nodemon ./bin/www.js"  新增语句
    如果是线上环境
    "prd":"cross-env NODE_ENV=production pm2 ./bin/www.js" 
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "cross-env": "^5.2.0",
    "nodemon": "^1.19.1"
  }
}

运行

npm run dev 

成功

[nodemon] 1.19.1
[nodemon] to restart at any time, enter `rs`
[nodemon] watching: *.*
[nodemon] starting `node ./bin/www.js`
[nodemon] clean exit - waiting for changes before restart

你可能感兴趣的:(node.js 路由)