首页 > 解决方案 > nodemon 向我显示此错误如何解决?

问题描述

"scripts": {
    "start": "node server.js",
    "server": "nodemon server.js"
  },

将此添加到我的 package.json 中,然后运行npm run server它启动的 commond,nodemon server.js但在重新启动时它向我显示此错误

[nodemon] restarting due to changes... 
(node:17784) UnhandledPromiseRejectionWarning: Error: Command failed: wmic process where (ParentProcessId=24008) get ProcessId 2> nul
    at checkExecSyncError (child_process.js:616:11)
    at execSync (child_process.js:652:15)
    at kill (C:\Users\shreya\AppData\Roaming\npm\node_modules\nodemon\lib\monitor\run.js:337:26)
    at Function.run.kill (C:\Users\shreya\AppData\Roaming\npm\node_modules\nodemon\lib\monitor\run.js:425:7)
    at Bus.<anonymous> (C:\Users\shreya\AppData\Roaming\npm\node_modules\nodemon\lib\monitor\run.js:495:7)
    at Bus.emit (events.js:327:22)
    at restartBus (C:\Users\shreya\AppData\Roaming\npm\node_modules\nodemon\lib\monitor\watch.js:228:7)
    at FSWatcher.filterAndRestart (C:\Users\shreya\AppData\Roaming\npm\node_modules\nodemon\lib\monitor\watch.js:212:16)
    at FSWatcher.emit (events.js:315:20)
    at FSWatcher.emitWithAll (C:\Users\shreya\AppData\Roaming\npm\node_modules\nodemon\node_modules\chokidar\index.js:540:8)
(node:17784) 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: 2)

这是我的 server.js 代码

标签: node.jsreactjsnodemon

解决方案


尝试更新 nodemon

npm i nodemon --global

推荐阅读