我正在开发MERN网络应用程序,并尝试同时运行客户端和 npm的服务器运行dev,但出现此错误。
发生错误时 执行命令:npm运行clientError:生成cmd.exe ENOENT 在_errnoException(util.js:1022:11) 在Process.ChildProcess._handle.onexit(内部/child_process.js:190:19) 在onErrorNT(internal / child_process.js:372:16) 在_combinedTickCallback(内部/进程/next_tick.js:138:11) 在process._tickCallback(内部/进程/next_tick.js:180:9) 在Function.Module.runMain(module.js:695:11) 在启动时(bootstrap_node.js:188:16) 在bootstrap_node.js:609:3执行命令时发生错误: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"
}
答案 0 :(得分:0)
我遇到了类似的问题,我要做的是转到系统Environment variables
并设置可能被错误删除的系统变量。
变量名 = PATH
变量值 = C:\Windows\System32\
转到> Control Panel\System and Security\System\Advance system setting\Enviroment variable
并设置系统变量路径C:\Windows\System32\
变量,然后重新启动系统。
答案 1 :(得分:0)
看看您的 client / package.json 。
您必须具有以下脚本:
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
}
答案 2 :(得分:0)
在你的服务器 package.json 上使用这一行而不是你当前的行
"dev": "concurrently \"npm run server\" \"cd client && npm start\""
事情可能是因为你的 dev 命令为客户端指定了 npm start 但它不知道在哪里可以找到。