问题描述
package.json 中的脚本
"scripts": {
"start": "node back-end/server.js","server": "nodemon back-end/server.js","client": "npm start --prefix front-end","dev": "concurrently \"npm run server\" \"npm run client\"","test": "echo \"Error: no test specified\" && exit 1"
},
$ npm run dev
> 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 (node:internal/child_process:282:19)
[0] at onErrorNT (node:internal/child_process:480:16)
[0] at processticksAndRejections (node:internal/process/task_queues:81:21)
[1] Error occurred when executing command: npm run client
[1] Error: spawn cmd.exe ENOENT
[1] at Process.ChildProcess._handle.onexit (node:internal/child_process:282:19)
[1] at onErrorNT (node:internal/child_process:480:16)
[1] at processticksAndRejections (node:internal/process/task_queues:81:21)
[1] npm run client exited with code -4058
[0] npm run server exited with code -4058 ```
解决方法
尝试将 "dev": "concurrently \"npm run server\" \"npm run client\"",
替换为
"dev": "npm run server && npm run client",