如何使用" nodemon"来运行快递的脚手架简单的"节点"命令,不使用" npm start"命令?

时间:2016-03-01 08:22:14

标签: javascript node.js express

我想我必须更改我的package.json文件,但我不知道在哪里? 这是我的package.json

{
  "name": "xyz",
  "version": "0.0.0",
  "private": true,
  "scripts": {
    "start": "node ./bin/www"
  },
  "dependencies": {
    "body-parser": "^1.13.3",
    "cookie-parser": "~1.3.5",
    "debug": "~2.2.0",
    "express": "~4.13.1",
    "jade": "~1.11.0",
    "mongoose": "^4.4.5",
    "morgan": "~1.6.1",
    "serve-favicon": "~2.3.0"
  }
}

1 个答案:

答案 0 :(得分:2)

为main添加条目,如下所示,并执行nodemon

{
  "name": "xyz",
  "version": "0.0.0",
  "private": true,
  "scripts": {
    "start": "node ./bin/www"
  },
  "main": "./bin/www",
  "dependencies": {
    "body-parser": "^1.13.3",
    "cookie-parser": "~1.3.5",
    "debug": "~2.2.0",
    "express": "~4.13.1",
    "jade": "~1.11.0",
    "mongoose": "^4.4.5",
    "morgan": "~1.6.1",
    "serve-favicon": "~2.3.0"
  }
}

然后做

nodemon

现在应该与npm start

完全相同

希望这有帮助!