"与 MERN 同时"npm run server" "npm run client""的错误



首先,我想为拼写错误道歉,我不是很好。

我在启动mern服务器时遇到问题。。。我想用"npmrun-dev"来运行它。此命令行执行"npm-run server"one_answers"npm-run-client"。以下是我的错误:

C: \Users\Jérémy\Desktop\Rendu\MERN\MERN_d04>npm运行dev

mern_d04@1.0.0 dev C:UsersJérémyDesktopRenduMERNMERN_d04
concurrently "npm run server" "npm run client"
[0] Error occurred when executing command: npm run server
[0] Error: spawn cmd.exe ENOENT
[0]     at Process.ChildProcess._handle.onexit (internal/child_process.js:267:19)
[0]     at onErrorNT (internal/child_process.js:467:16)
[0]     at processTicksAndRejections (internal/process/task_queues.js:84:21)
[1] Error occurred when executing command: npm run client
[1] Error: spawn cmd.exe ENOENT
[1]     at Process.ChildProcess._handle.onexit (internal/child_process.js:267:19)
[1]     at onErrorNT (internal/child_process.js:467:16)
[1]     at processTicksAndRejections (internal/process/task_queues.js:84:21)
[1] npm run client exited with code -4058
[0] npm run server exited with code -4058
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! mern_d04@1.0.0 dev: `concurrently "npm run server" "npm run client"`>npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the mern_d04@1.0.0 dev script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR!     C:UsersJérémyAppDataRoamingnpm-cache_logs2020-04-22T19_45_03_286Z-debug.log

这是我的根包.json:

{
"name": "mern_d04",
"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": {
"bcryptjs": "^2.4.3",
"body-parser": "^1.19.0",
"concurrently": "^5.1.0",
"express": "^4.17.1",
"is-empty": "^1.2.0",
"jsonwebtoken": "^8.5.1",
"mongoose": "^5.9.10",
"passport": "^0.4.1",
"passport-jwt": "^4.0.0",
"validator": "^13.0.0"
},
"devDependencies": {
"nodemon": "^2.0.3"
}
}

这是我的客户端软件包.json:

{
"name": "client",
"version": "0.1.0",
"private": true,
"dependencies": {
"@testing-library/jest-dom": "^4.2.4",
"@testing-library/react": "^9.5.0",
"@testing-library/user-event": "^7.2.1",
"axios": "^0.19.2",
"classnames": "^2.2.6",
"jwt-decode": "^2.2.0",
"react": "^16.13.1",
"react-dom": "^16.13.1",
"react-redux": "^7.2.0",
"react-router-dom": "^5.1.2",
"react-scripts": "3.4.1",
"redux": "^4.0.5",
"redux-thunk": "^2.3.0"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"proxy": "http://localhost:5000",
"eslintConfig": {
"extends": "react-app"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}

我试过很多东西,最令人惊讶的是:它在我朋友的电脑上工作,但在我的电脑上不工作。有人能帮我吗?:(

编辑:节点版本:13.0.0

编辑:找到了解决方案。我"刚刚"在环境变量中有一个变量"C:\Windows\System32":(

我也面临同样的问题。如果这个代码有效,你可以试试这个。。在你的根包.json 上

"scripts": {
"start": "node index",
"server": "nodemon index",
"client": "npm run start --prefix client",
"dev": "concurrently "npm run server" "cd client && npm start""
},

然后从根目录类型npm运行dev

节点模块与当前系统不兼容。您可以删除根级别和客户端级别的node_modules文件夹。然后再次安装两个node_module。

相关内容

  • 没有找到相关文章

最新更新