简体   繁体   English

当我尝试使用npm start命令运行React App时出错

[英]Error when I try run a React App with npm start command

I create a new React Project and I try to start it with the command npm start but I have this error: 我创建了一个新的React Project,并尝试使用命令npm start来启动它,但是我npm start这个错误:

events.js:174
      throw er; // Unhandled 'error' event
      ^

Error: spawn cmd ENOENT
    at Process.ChildProcess._handle.onexit (internal/child_process.js:240:19)
    at onErrorNT (internal/child_process.js:415:16)
    at process._tickCallback (internal/process/next_tick.js:63:19)
Emitted 'error' event at:
    at Process.ChildProcess._handle.onexit (internal/child_process.js:246:12)
    at onErrorNT (internal/child_process.js:415:16)
    at process._tickCallback (internal/process/next_tick.js:63:19)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! primera-app@0.1.0 start: `react-scripts start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the primera-app@0.1.0 start 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:\Users\Felipe\AppData\Roaming\npm-cache\_logs\2019-08-11T15_55_25_058Z-debug.log

I try a lot of things but nothing works. 我尝试了很多事情,但没有任何效果。

I had the same problem on Windows about two months ago. 大约两个月前,我在Windows上遇到了同样的问题。 I solved it downgrading react-scripts to the version 2.1.8 . 我解决了将react-scripts降级到2.1.8版本的问题。 To do so: 为此:

  1. Delete node_modules directory. 删除node_modules目录。
  2. Edit package.json file to downgrade react-scripts . 编辑package.json文件以降级react-scripts It should look like this: "react-scripts": "2.1.8" . 它应该看起来像这样: "react-scripts": "2.1.8"
  3. Go to the project folder: cd my-app . 转到项目文件夹: cd my-app
  4. Run npm install . 运行npm install
  5. Run npm start . 运行npm start

If this doesn't work, please check your system variables on Windows and make sure C:\\Windows\\System32\\ variable is set as shown here or here . 如果这不起作用,请在Windows上检查系统变量,并确保按此处此处所示设置C:\\Windows\\System32\\变量。

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

相关问题 为什么当我尝试运行我的应用程序时“npm start”会给我错误? - Why does “npm start” give me error when i try run my app? 当我尝试使用 npm 运行反应应用程序时出现此错误? - I am getting this error when I try to run react app with npm? 在创建反应项目时在“npx create-react-app my-app”之后运行命令“npm start”时出错 - getting error when run command 'npm start' after 'npx create-react-app my-app' in creating a react project Npm 尝试创建反应应用程序时出错 - Npm Error when I try to create the react app 运行 npm start 创建 React 应用程序时缺少脚本 - Missing Script when I run npm start to create React app 当我尝试运行npm install时出错 - Error when I try to run npm install 当我尝试在 Windows 命令提示符下运行 `npm run test` 时出错 - Error when I try to run `npm run test` in windows command prompt 我试图运行命令“npm run start”,它在 react js 中显示了这个错误 - I tried to run command “npm run start ” and it showd up with this error in react js 如果我运行命令 npm install create-react-app my-app,我继续收到错误 - If I run the command npm install create-react-app my-app, I keep on receiving Error 尝试在 React 项目上运行 npm 构建时出错 - error when try to run npm build on react project
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM