命令失败:在 Express 应用程序中更新 npm 后的 wmic 进程
Command failed: wmic process after updating npm in Express app
在我的 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 做一些事情。
你检查nodemon -v,如果不能识别nodemon那么npm install -g nodemon -> nodemon app.js
[在此处输入图片描述][1]
[1]: https://i.stack.imgur.com/UbQLM.png
尝试全局安装 nodemon 版本 2.0.7
首先安装当前版本npm uninstall -g nodemon
然后写命令 npm i -g nodemon@2.0.7
至少对我有用:)
未找到 system32 文件夹的路径。一旦我将它添加到系统路径,它就会工作,因为它 should.The 问题不在于 nodemon,而是我的系统在环境变量中缺少 system32 文件夹的路径。 System32 文件夹包含 Windows 正常运行所需的重要操作系统文件。对于这种情况,命令不会自动刷新 (nodemon)。
将您的 nodemon
更新到最新版本将解决此问题。
npm install nodemon
运行 以上命令会将 nodemon
更新到最新版本。
可能是新版本的 nodemon 导致的。因此,我已将版本降级为 2.0.7,这对我来说工作正常!
npm uninstall nodemon
npm install nodemon@2.0.7 --save-dev
如果没有解决,您可以卸载 nodemone 并重新安装,这对我有用。
在我的 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 做一些事情。
你检查nodemon -v,如果不能识别nodemon那么npm install -g nodemon -> nodemon app.js
[在此处输入图片描述][1] [1]: https://i.stack.imgur.com/UbQLM.png
尝试全局安装 nodemon 版本 2.0.7
首先安装当前版本npm uninstall -g nodemon
然后写命令 npm i -g nodemon@2.0.7
至少对我有用:)
未找到 system32 文件夹的路径。一旦我将它添加到系统路径,它就会工作,因为它 should.The 问题不在于 nodemon,而是我的系统在环境变量中缺少 system32 文件夹的路径。 System32 文件夹包含 Windows 正常运行所需的重要操作系统文件。对于这种情况,命令不会自动刷新 (nodemon)。
将您的 nodemon
更新到最新版本将解决此问题。
npm install nodemon
运行 以上命令会将 nodemon
更新到最新版本。
可能是新版本的 nodemon 导致的。因此,我已将版本降级为 2.0.7,这对我来说工作正常!
npm uninstall nodemon
npm install nodemon@2.0.7 --save-dev
如果没有解决,您可以卸载 nodemone 并重新安装,这对我有用。