【问题标题】:Command failed: wmic process after updating npm in Express app命令失败:在 Express 应用中更新 npm 后的 wmic 进程
【发布时间】:2021-09-15 22:20:42
【问题描述】:

在我的 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 做一些事情。

【问题讨论】:

    标签: node.js express npm nodemon


    【解决方案1】:

    如果没有解决,您可以卸载 nodemone 并重新安装,这对我有用。

    【讨论】:

      【解决方案2】:

      未找到 system32 文件夹的路径。一旦我将它添加到系统路径,它就可以正常工作。问题不在于 nodemon,而是我的系统在环境变量中缺少 system32 文件夹的路径。 System32 文件夹包含 Windows 正常运行所需的重要操作系统文件。对于这种情况,该命令不会自动刷新 (nodemon)。

      【讨论】:

      • 对不起,你能解释一下吗?我该怎么做?
      • 请转到本地文件 C: -> Windows -> System32。然后复制文件路径。在高级系统设置的环境变量中添加新的系统路径。
      【解决方案3】:

      可能是新版本的 nodemon 导致了这种情况。所以,我已将版本降级为 2.0.7,这对我来说很好用!

      npm uninstall nodemon
      npm install nodemon@2.0.7 --save-dev
      

      【讨论】:

        【解决方案4】:

        将您的nodemon 更新到最新版本将解决此问题。

        npm install nodemon
        

        运行上述命令会将nodemon 更新到最新版本。

        【讨论】:

          【解决方案5】:

          尝试全局安装 nodemon 2.0.7 版

          先安装当前版本npm uninstall -g nodemon 然后写命令npm i -g nodemon@2.0.7

          至少它对我有用:)

          【讨论】:

          • 不,它对我不起作用。我安装了一个调试版本。虽然它不再给我命令失败的错误,但文件内容没有更新。
          【解决方案6】:

          你检查 nodemon -v,如果 nodemon 不被识别然后 npm install -g nodemon -> nodemon app.js

          [在此处输入图片描述][1] [1]:https://i.stack.imgur.com/UbQLM.png

          【讨论】:

          • nodemon 已安装。它正在工作一次。但是每当我刷新文件时,就会出现错误“wmic process command failed”。
          • 您已经使用脚本运行命令 nodemon 了吗?例如:npm start,我通过在 ternimal 中键入“nodemon server.js”解决了这个问题
          猜你喜欢
          • 2020-01-19
          • 1970-01-01
          • 2023-03-16
          • 1970-01-01
          • 1970-01-01
          • 2020-02-29
          • 1970-01-01
          • 1970-01-01
          • 2017-11-02
          相关资源
          最近更新 更多