nodemon 将运行app.js文件
app.js代码如下
const express = require('express');
const app = express();
app.get('/', (req, res) => {
res.send('hello world')
})
app.listen(3000,()=>{console.log("Server running at http://127.0.0.1:3000/");})
nodemon 第一次启动正常
[nodemon] 2.0.12
[nodemon] to restart at any time, enter `rs`
[nodemon] watching path(s): *.*
[nodemon] watching extensions: js,mjs,json
[nodemon] starting `node app.js`
Server running at http://127.0.0.1:3000/
然后直接ctrl+s保存,报如下错误
[nodemon] restarting due to changes...
(node:2484) UnhandledPromiseRejectionWarning: Error: Command failed: wmic process where (ParentProcessId=20160) get ProcessId 2> nul
...
(Use `node --trace-warnings ...` to show where the warning was created)
(node:2484) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:2484) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js
process with a non-zero exit code.
尝试过后发现是这一块代码的问题
app.listen(3000,()=>{console.log("Server running at http://127.0.0.1:3000/");})
目前无法正面解决问题,现在改用另外一个工具 supervisor
,问题从侧面来说已经解决,谢谢拉