如何更改nodemon默认启动文件?

时间:2018-01-09 17:06:46

标签: nodemon

我有一个网络应用程序。我想用它来使用nodemon。要启动我的应用程序,需要运行' node ./bin/www' ,但nodemon默认运行另一个文件。而我的网络应用程序并不可行。

当我输入cmd时

nodemon
我得到了:

[nodemon] 1.14.10
[nodemon] to restart at any time, enter `rs`
[nodemon] watching: *.*
[nodemon] starting `node app.js`

但我希望将node app.js更改为node ./bin/www

的默认启动文件

我该怎么做?

的package.json

{
  "name": "loc8r",
  "version": "0.0.0",
  "private": true,
  "scripts": {
    "start": "node ./bin/www"
  },
  "dependencies": {
    "body-parser": "~1.18.2",
    "cookie-parser": "~1.4.3",
    "debug": "~2.6.9",
    "express": "~4.15.5",
    "jade": "~1.11.0",
    "mongoose": "4.13.9",
    "morgan": "~1.9.0",
    "nodemon": "^1.14.9",
    "readline": "1.3.0",
    "request": "^2.83.0",
    "serve-favicon": "~2.4.5"
  },
  "main": "app.js",
  "devDependencies": {},
  "author": "",
  "license": "ISC",
  "description": ""
}

1 个答案:

答案 0 :(得分:1)

nodemon应该选择"main": "file_to_be_executed.js",中的文件,因此如果www是您要执行的文件,请将"main": "app.js",更改为:"main": "./bin/www",