[英]I am having an error creating a react app in my probably due to an issue in my react-scripts
I have installed the npm create-react-app and was given the following error(shown below) when i tried to npm start as a trial.我已经安装了 npm create-react-app,当我尝试将 npm start 作为试用版时,出现以下错误(如下所示)。 I am a beginner and i tried to delete my node modules, package.json and package-lock.jason and reinstalled them.
我是初学者,我尝试删除我的节点模块 package.json 和 package-lock.jason 并重新安装它们。 I updated all the current dependencies and did an npm audit fix but the error persists.
我更新了所有当前的依赖项并进行了 npm 审计修复,但错误仍然存在。 Any advice would be greatly appreciated.
任何建议将不胜感激。
Node version 12.14.1 create-react-app version 3.3.0 Windows 10节点版本 12.14.1 create-react-app 版本 3.3.0 Windows 10
events.js:200
throw er; // Unhandled 'error' event
^
Error: spawn cmd ENOENT
at Process.ChildProcess._handle.onexit (internal/child_process.js:264:19)
at onErrorNT (internal/child_process.js:456:16)
at processTicksAndRejections (internal/process/task_queues.js:81:21)
Emitted 'error' event on ChildProcess instance at:
at Process.ChildProcess._handle.onexit (internal/child_process.js:270:12)
at onErrorNT (internal/child_process.js:456:16)
at processTicksAndRejections (internal/process/task_queues.js:81: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! my-app@0.1.0 start: `react-scripts start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the my-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\pandh\AppData\Roaming\npm-cache\_logs\2020-01-22T10_07_03_047Z-debug.log
我不明白这个问题,但是您可以尝试执行npm init -y
然后执行npx create-react-app app-name
而不是安装命令。
This is most likely, issue related to react-scripts
not being installed globally or you have an old version installed.这很可能是与未全局安装
react-scripts
相关的问题,或者您安装了旧版本。
I suggest doing these three steps:我建议做这三个步骤:
$ npm install -g react-scripts
$ rm -rf node_modules
to remove the existing modules. $ rm -rf node_modules
删除现有模块。$ npm install
to re-install the project dependencies. $ npm install
重新安装项目依赖。So i managed to resolve the issue by adding the default variables in your machines PATH: C:\\Windows\\system32
C:\\Windows
C:\\Windows\\System32\\Wbem
所以我设法通过在你的机器路径中添加默认变量来解决这个问题:
C:\\Windows\\system32
C:\\Windows
C:\\Windows\\System32\\Wbem
any other paths can be added to the end.任何其他路径都可以添加到最后。 Remember to have the npm paths as well:
C:\\Program Files\\nodejs
C:\\Users{yourName}\\AppData\\Roaming\\npm
记住还有 npm 路径:
C:\\Program Files\\nodejs
C:\\Users{yourName}\\AppData\\Roaming\\npm
I found this resolution here: https://github.com/facebook/create-react-app/issues/8337我在这里找到了这个解决方案: https : //github.com/facebook/create-react-app/issues/8337
Thanks for all the suggestions.感谢所有的建议。
First Remove the node_modules directory and reinstalling again using npm install
首先删除 node_modules 目录并使用
npm install
重新npm install
and then killall node
然后
killall node
then npm start
然后
npm start
Most of the time this error occurs when there are more than one app is using the node server大多数情况下,当有多个应用程序正在使用节点服务器时会发生此错误
You can also try it by changing the port您也可以通过更改端口来尝试
Create a .env file at your project root and specify the port number there.在您的项目根目录创建一个.env文件并在那里指定端口号。 Like:
喜欢:
PORT=3005
If that doesn't work either that means you don't have the multiple apps running problem如果这也不起作用,则意味着您没有运行多个应用程序的问题
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.