npm从React应用程序启动时出现错误 [英] Getting error when npm start with React application

查看:52
本文介绍了npm从React应用程序启动时出现错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

每当我使用 npx create-react-app test 创建一个新的React文件夹时,我都会遇到这个问题. npm start 不起作用,并在终端中引发此错误消息

 >test@0.1.0开始C:\ Users \ franc \ Desktop \ test>反应脚本开始我「wds」:项目运行在http://192.168.56.1/我「wds」:webpack输出从提供我的名字:不是来自Webpack的内容是从C:\ Users \ franc \ Desktop \ test \ public提供的我「wds」:404会回退到/正在启动开发服务器...events.js:288投掷者//未处理的错误"事件^错误:生成cmd ENOENT在Process.ChildProcess._handle.onexit(内部/child_process.js:267:19)在onErrorNT(internal/child_process.js:469:16)在processTicksAndRejections(internal/process/task_queues.js:84:21)在以下位置的ChildProcess实例上引发了错误"事件:在Process.ChildProcess._handle.onexit(内部/child_process.js:273:12)在onErrorNT(internal/child_process.js:469:16)在processTicksAndRejections(internal/process/task_queues.js:84:21){errno:"ENOENT",代码:"ENOENT",syscall:"spawn cmd",路径:"cmd",spawnargs:['/s','/c','start','"','/b','"http://localhost:3000"']}npm ERR!代码ELIFECYCLEnpm ERR!errno 1npm ERR!test@0.1.0 start:`react-scripts start`npm ERR!退出状态1npm ERR!npm ERR!在test@0.1.0启动脚本处失败.npm ERR!npm可能不是问题.上面可能还有其他日志记录输出.npm ERR!可以在以下位置找到此运行的完整日志:npm ERR!C:\ Users \ franc \ AppData \ Roaming \ npm-cache \ _logs \ 2020-03-23T00_10_45_653Z-debug.log 

有人知道如何解决吗?

解决方案

我通过在环境变量的PATH中添加 C:\ Windows \ System32 并重新启动系统来解决了我的问题.

I'm having this problem whenever I create a new React folder using npx create-react-app test. npm start does not work and throws this error message in the terminal

> test@0.1.0 start C:\Users\franc\Desktop\test
> react-scripts start

i 「wds」: Project is running at http://192.168.56.1/
i 「wds」: webpack output is served from
i 「wds」: Content not from webpack is served from C:\Users\franc\Desktop\test\public
i 「wds」: 404s will fallback to /
Starting the development server...

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

Error: spawn cmd ENOENT
    at Process.ChildProcess._handle.onexit (internal/child_process.js:267:19)
    at onErrorNT (internal/child_process.js:469:16)
    at processTicksAndRejections (internal/process/task_queues.js:84:21)
Emitted 'error' event on ChildProcess instance at:
    at Process.ChildProcess._handle.onexit (internal/child_process.js:273:12)
    at onErrorNT (internal/child_process.js:469:16)
    at processTicksAndRejections (internal/process/task_queues.js:84:21) {
  errno: 'ENOENT',
  code: 'ENOENT',
  syscall: 'spawn cmd',
  path: 'cmd',
  spawnargs: [ '/s', '/c', 'start', '""', '/b', '"http://localhost:3000"' ]
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! test@0.1.0 start: `react-scripts start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the test@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\franc\AppData\Roaming\npm-cache\_logs\2020-03-23T00_10_45_653Z-debug.log

Does anybody know how to solve it?

解决方案

I solved my problem by adding C:\Windows\System32 to the PATH in my environment variables and restarting the system.

这篇关于npm从React应用程序启动时出现错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆