Leaf_Yi 2021-08-10 13:21 采纳率: 81.3%
浏览 95
已结题

nodemon 第一次启动正常,保存第二次启动报错,已找到关键代码行,但不知道原因

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/");})
  • 写回答

2条回答 默认 最新

  • Leaf_Yi 2021-08-12 23:22
    关注

    目前无法正面解决问题,现在改用另外一个工具 supervisor ,问题从侧面来说已经解决,谢谢拉

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

问题事件

  • 系统已结题 8月21日
  • 已采纳回答 8月13日
  • 修改了问题 8月10日
  • 修改了问题 8月10日
  • 展开全部