1
votes

I am working on MERN web application and trying to run both client and server with npm run dev but getting this error.

Error occured when executing command: npm run clientError: spawn cmd.exe ENOENT at _errnoException (util.js:1022:11) at Process.ChildProcess._handle.onexit (internal/child_process.js:190:19) at onErrorNT (internal/child_process.js:372:16) at _combinedTickCallback (internal/process/next_tick.js:138:11) at process._tickCallback (internal/process/next_tick.js:180:9) at Function.Module.runMain (module.js:695:11) at startup (bootstrap_node.js:188:16) at bootstrap_node.js:609:3Error occured when executing command: npm run clientError: spawn cmd.exe ENOENT

//package.json in server 
{
  "name": "mern-list",
  "version": "1.0.0",
  "description": "",
  "main": "server.js",
  "scripts": {
    "client-install": "npm install --prefix client",
    "start": "node server.js",
    "server": "nodemon server.js",
    "client": "npm start --prefix client",
    "dev": "concurrently \"npm run server\" \"npm run client\""
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "body-parser": "^1.18.3",
    "concurrently": "^3.6.0",
    "express": "^4.16.3",
    "mongoose": "^5.2.0"
  },
  "devDependencies": {
    "nodemon": "^1.17.5"
  }
}

package.json in client
{
  "name": "client",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "react": "^16.4.1",
    "react-dom": "^16.4.1",
    "react-scripts": "1.1.4"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test --env=jsdom",
    "eject": "react-scripts eject"
  },
  "proxy": "http://localhost:5000"
}
3
Hi, I too m getting the same error and i cant figure out why ? is it something to do with windows.... please help us out here ?bikash
@abhishek any update over this issue? How did you resolve this ?Tammy
@TanmoySarkar I ran client and server on different cmd. However its not a correct approach.Abhishek Konnur
@AbhishekKonnur then how to deploy that in server? by two different command ?Tammy
Just run "node server.js" in one cmd and "npm start" in another cmd.Abhishek Konnur

3 Answers

0
votes

I had a similar issue and what I did was to goto my system Environment variables and set my system variables which may have been mistakenly deleted.

Variable name = PATH

Variable value = C:\Windows\System32\

Goto > Control Panel\System and Security\System\Advance system setting\Enviroment variable and set system variables path C:\Windows\System32\ variable and restart your System.

0
votes

Take a look at your client/package.json.
You have to have these scripts:

"scripts": {
  "start": "react-scripts start",
  "build": "react-scripts build",
  "test": "react-scripts test --env=jsdom",
  "eject": "react-scripts eject"
 }
0
votes

on your server package.json use this line instead of your current line

"dev": "concurrently \"npm run server\" \"cd client && npm start\""

things may be happened because of your dev command it was specified npm start for the client but it didn't know where to find that.