繁体   English   中英

运行 npm run dev 时出错

[英]Error on running npm run dev

我正在开发 MERN Web 应用程序并尝试使用 npm run dev 运行客户端和服务器,但收到此错误。

执行命令时发生错误: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) 在启动时 (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"
}

我有一个类似的问题,我所做的是转到我的系统Environment variables并设置可能被错误删除的系统变量。

变量名= PATH

变量值= C:\\Windows\\System32\\

转到> Control Panel\\System and Security\\System\\Advance system setting\\Enviroment variable并设置系统变量路径C:\\Windows\\System32\\变量并重新启动系统。

看看你的client/package.json
你必须有这些脚本:

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

在您的服务器 package.json 上使用此行而不是您当前的行

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

事情可能会因为您的 dev 命令而发生,它为客户端指定了 npm start 但它不知道在哪里可以找到它。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM