在我的app.js里
const app = require("express")();
const port = 3000;
app.get("/", (req, res) => {
res.send("hello world");
});
app.listen(port, () => {
console.log("server running!");
});
这个错误是在我保存/更新app.js文件后产生的,
(node:4196) UnhandledPromiseRejectionWarning: Error: Command failed: wmic process where (ParentProcessId=5740) get ProcessId 2> nul
at checkExecSyncError (child_process.js:630:11)
at execSync (child_process.js:666:15)
at kill (C:\Users\SANTOSH\Desktop\nodesql\node_modules\nodemon\lib\monitor\run.js:337:26)
at Function.run.kill (C:\Users\SANTOSH\Desktop\nodesql\node_modules\nodemon\lib\monitor\run.js:425:7)
at Bus.<anonymous> (C:\Users\SANTOSH\Desktop\nodesql\node_modules\nodemon\lib\monitor\run.js:495:7)
at Bus.emit (events.js:327:22)
at restartBus (C:\Users\SANTOSH\Desktop\nodesql\node_modules\nodemon\lib\monitor\watch.js:228:7)
at FSWatcher.filterAndRestart (C:\Users\SANTOSH\Desktop\nodesql\node_modules\nodemon\lib\monitor\watch.js:212:16)
at FSWatcher.emit (events.js:315:20)
at FSWatcher.emitWithAll (C:\Users\SANTOSH\Desktop\nodesql\node_modules\chokidar\index.js:540:8)
(node:4196) 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)
Package.json文件,
{
"name": "nodesql",
"version": "1.0.0",
"description": "",
"main": "app.js",
"scripts": {
"start": "nodemon app.js"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"body-parser": "^1.19.0",
"express": "^4.17.1",
"mysql2": "^2.2.5",
"sequelize": "^6.6.4",
"sequelize-cli": "^6.2.0"
},
"devDependencies": {
"nodemon": "^2.0.9"
}
}
今天我更新了我的npm到7.19.1,之后我得到了这个错误。否则,它必须与nodemon做一些事情。
6条答案
按热度按时间pkbketx91#
可能是新版本的nodemon导致了这个问题。所以,我已经降级到2.0.7版本,这对我来说很好!
voj3qocg2#
检查nodemon -v,如果nodemon未被识别,则npm install -g nodemon -> nodemon app.js
[在此处输入图像描述][1] [1]:https://i.stack.imgur.com/UbQLM.png
mqxuamgl3#
尝试全局安装nodemon verson 2.0.7
首先安装当前版本
npm uninstall -g nodemon
,然后编写命令npm i -g nodemon@2.0.7
至少对我有效:)
2nc8po8w4#
将
nodemon
更新到最新版本将解决此问题。运行以上命令将
nodemon
更新到最新版本。u0njafvf5#
找不到system32文件夹的路径。当我将它添加到系统路径时,它就像它应该的那样工作了。问题不是nodemon,而是我的系统在环境变量中缺少system32文件夹的路径。System32文件夹包含Windows需要的重要操作系统文件,以便正常运行。在这种情况下,命令不会自动刷新(nodemon)。
rwqw0loc6#
如果没有解决,你可以卸载nodemone并重新安装它,这对我很有效。