Error in “npm start” for newly created project

混江龙づ霸主 提交于 2019-12-13 04:08:13

问题


I just created a react js project. Then I run "npm start" for run the project. this error come and I am stuck here for 1 day now. I have already have other reactJS projects. This error came for all other projects. That's why I tried it with new project. So I confirmed by creating new project. Error is not in my project.

I already tried.

  • Delete node_module folder then npm install
  • clear node cache.
  • Reinstall node.js
  • Create new project.
  • Reduce the version of 'react-script'
  • Uninstall node.js and delete all files in c drive with the name of "node"
  • Installing old version of node.js

Error is,

C:\Suranga\ReactJS\JMSL\my_app>npm start

> my_app@0.1.0 start C:\Suranga\ReactJS\JMSL\my_app
> react-scripts start
> Starting the development server...
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! 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\Administrator\AppData\Roaming\npm-cache\_logs\2019-09-10T15_10_01_727Z-debug.log
C:\Suranga\ReactJS\JMSL\my_app>

回答1:


For archive purposes, here is the solution reported by OP.

Downgrade to react-scripts 2.1.8.

create-react-app my-app
cd my-app
npm install react-scripts@2.1.8
npm start



回答2:


First make sure you are in the right application folder that was created with create-react-app. Else, trying running npm install in the folder.




回答3:


Still had same problem for others. Previous solution is not success for those projects. finally I did it with following steps.

1) Install Chocolatey for windows (https://chocolatey.org/)
2) Install npm by using choco ("choco install nodejs-latest")
3) npm start



来源:https://stackoverflow.com/questions/57874073/error-in-npm-start-for-newly-created-project

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!