Node.js 在windows中运行react js应用程序时出错
我正在使用Node.js 在windows中运行react js应用程序时出错,node.js,reactjs,npm,Node.js,Reactjs,Npm,我正在使用节点(12.16.2)和npm(6.14.4)和createreact应用程序(3.4.1)。 使用create react app{app name}创建应用程序并转到其目录后,我使用npm start运行它,我看到下面的错误。 我认为问题在于我的npm没有繁殖。 以下是错误: > tesssssst@0.1.0 start C:\Users\Yasaman\Desktop\tesssssst > react-scripts start i 「wds」: Project
节点(12.16.2)
和npm(6.14.4)
和createreact应用程序(3.4.1)
。
使用create react app{app name}
创建应用程序并转到其目录后,我使用npm start
运行它,我看到下面的错误。
我认为问题在于我的npm没有繁殖。
以下是错误:
> tesssssst@0.1.0 start C:\Users\Yasaman\Desktop\tesssssst
> react-scripts start
i 「wds」: Project is running at http://0.0.0.0:3000/
i 「wds」: webpack output is served from
i 「wds」: Content not from webpack is served from C:\Users\Yasaman\Desktop\tesssssst\public
i 「wds」: 404s will fallback to /
Starting the development server...
events.js:287
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! tesssssst@0.1.0 start: `react-scripts start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the tesssssst@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\Yasaman\AppData\Roaming\npm-cache\_logs\2020-04-26T20_33_07_370Z-debug.log
如何解决此问题?对于荒谬的问题,请寻求荒谬的解决方案,这只是因为您的环境设置,您应该设置Windows环境变量,将
%SystemRoot%\system32
添加到您的路径,如果正确,请告诉我将其作为答案发布:
%SystemRoot%\system32
本地
create-react-app
似乎无法与Windows配合使用。尝试将其删除npm uninstall-g create react app
并改用npx create react app
试试@awran5在评论中写的内容。此外,CRA默认使用纱线来制作项目,而不是NPM,因此您应该尝试纱线开始
;确保CRA在制作项目时使用哪个包管理器。最后(尽管这不是问题的原因),尝试使用Powershell内核,而不是CMD和Windows终端;您将获得更好的结果和工作流程。@awran5我多年来一直在使用Powershell Core和React、CRA、React Native以及许多其他节点和Python开发堆栈,没有任何问题。@Yasaman.Mansouri,设置Windows环境变量,将%SystemRoot%\system32添加到您的路径中,如果正确,告诉我将其作为答案发布。@Yasaman.Mansouri正如AmerllicA所说,尝试将C:\Windows\System32
添加到前面提到的环境变量中的路径尝试这些谢谢您的帮助!我和这个问题纠缠了一个多星期!!