React App无法使用npm start启动服务器

时间:2019-05-26 09:40:35

标签: reactjs react-scripts

我使用CRA创建了一个新的react应用。启动开发服务器后,它将引发错误并退出。

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! cart-redux@0.1.0 start: `react-scripts start`                           
npm ERR! Exit status 1                                                           
npm ERR!                                                                         
npm ERR! Failed at the cart-redux@0.1.0 start script.                            
npm ERR! This is probably not a problem with npm. There is likely additional logg
ing output above.                                                                

npm ERR! A complete log of this run can be found in:                             
npm ERR!     C:\Users\HP\AppData\Roaming\npm-cache\_logs\2019-05-26T09_32_50_014Z
-debug.log  

react-scripts版本3.0.1避免使用“ npm start”。我尝试降级到2.1.8版,但效果很好。但是我不想每次都降级版本以使我的应用正常工作。 I tried following the similar case,但没有帮助。 遇到此问题的其他任何人,请帮助解决。

1 个答案:

答案 0 :(得分:1)

如果您尝试了this,但对您不起作用,那么这可能是一个反应脚本问题,因此要解决此问题,请尝试以下操作:

remove node_modules and lock files
edit package.json so the version of react-scripts is "2.1.8"
npm install
npm start

LTK怎么回事