首先安装supervisor
npm install -save supervisor
然后在package.json中更改启动命令
"scripts": {
"start": "supervisor ./bin/www", // 原命令 start: node./bin/www
},
注意,这里是 -save, 之前安装 -g ,在使用的时候报错
因为用 -g 的时候是全局安装,并不能保存到dependencies中
"dependencies": {
"cookie-parser": "~1.4.3",
"debug": "~2.6.9",
"express": "~4.16.0",
"http-errors": "~1.6.2",
"jade": "~1.11.0",
"morgan": "~1.9.0",
"supervisor": "^0.12.0" // 使用 -g 时 不能自动生成
}