4

In my app.js,

const app = require("express")();

const port = 3000;

app.get("/", (req, res) => {
  res.send("hello world");
});

app.listen(port, () => {
  console.log("server running!");
});

This error generated after I save / update the app.js file,

(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 file,

{
  "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"
  }
}

Today I updated my npm to 7.19.1, after that I am getting this error. Otherwise, it has to do something with nodemon.

Dinesh Rout
  • 91
  • 2
  • 8

6 Answers6

5

Maybe the new version of nodemon is causing this. So, I've degraded the version to 2.0.7 which is working fine for me!

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

You check nodemon -v, if nodemon is not recognized then npm install -g nodemon -> nodemon app.js

[enter image description here][1] [1]: https://i.stack.imgur.com/UbQLM.png

  • nodemon is installed. It is working for once. But whenever I refresh the file, the error "wmic process command failed" occurs. – Dinesh Rout Jul 08 '21 at 15:20
  • You have run command nodemon with scripts ? ex: npm start, I fixed this problem by way type "nodemon server.js" in ternimal – Thanh Trung Jul 09 '21 at 08:55
1

try installing nodemon verson 2.0.7 globally

first install the current version npm uninstall -g nodemon then write the command npm i -g nodemon@2.0.7

atleast it worked for me :)

  • 1
    No it didn't work for me. I installed a debug version. Although it is not giving me the command failed error anymore, but the file contents are not updated. – Dinesh Rout Jul 09 '21 at 10:36
1

The system32 folder's path was not found. As soon as I added it to the system path, it worked as it should.The problem was not with nodemon, it was my system that was missing the system32 folder's path in environment variables. System32 folder contains important operating system files that Windows needs in order to function properly. For this case the command was not automatically refreshing (nodemon).

Dinesh Rout
  • 91
  • 2
  • 8
  • sorry , could you please explain this? how i'm suppose to do that ? – cri_pava Sep 19 '21 at 14:21
  • Please go to Local files C: -> Windows -> System32. Then copy the file path. Add a new system path in environment variables in advanced system settings. – Dinesh Rout Sep 28 '21 at 04:20
1

Updating your nodemon to the latest version will resolve this issue.

npm install nodemon

Running above command will update nodemon to the latest version.

Deepak Singh
  • 71
  • 1
  • 1
0

If Not solving you can uninstall nodemone and install it again this worked for me.