npm start error with create-react-app

后端 未结 20 1860
长发绾君心
长发绾君心 2020-11-27 10:18

I have a project who I didn\'t touch for 2 weeks. I take it back and now when I try to run npm start I got this error.

> react-scripts start
         


        
相关标签:
20条回答
  • 2020-11-27 11:08

    As Dan said correctly,

    If you see this:

    npm ERR! UpScore@0.6.0 start: `react-scripts start`
    npm ERR! spawn ENOENT
    

    It just means something went wrong when dependencies were installed the first time.

    But I got something slightly different because running npm install -g npm@latest to update npm might sometimes leave you with this error:

    npm ERR! code ETARGET
    npm ERR! notarget No matching version found for npm@lates
    npm ERR! notarget In most cases you or one of your dependencies are requesting
    npm ERR! notarget a package version that doesn't exist.
    

    so, instead of running npm install -g npm@latest, I suggest running the below steps:

     npm i -g npm //which will also update npm
     rm -rf node_modules/ && npm cache clean // to remove the existing modules and clean the cache.
     npm install //to re-install the project dependencies.
    

    This should get you back on your feet.

    0 讨论(0)
  • 2020-11-27 11:08

    This occurs when the node_modules gets out of sync with package.json.

    Run the following at the root and any sub service /sub-folder that might have node_modules folder within it.

    rd node_modules /S /Q
    npm install
    
    0 讨论(0)
  • 2020-11-27 11:10

    Yes you should not install react-scripts globally, it will not work.

    I think i didn't use the --save when i first created the project (on another machine), so for me this fixed the problem :

    npm install --save react react-dom react-scripts
    
    0 讨论(0)
  • 2020-11-27 11:10

    incase you happened to be so unlucky like me that spent three(3) days in a row trying to solve this problem every solution proposed here failed me ... create a .env file in your project root and add this code SKIP_PREFLIGHT_CHECK=true. Good luck

    0 讨论(0)
  • 2020-11-27 11:14

    It occurred to me but none of the above worked.

    events.js:72
            throw er; // Unhandled 'error' event
                  ^
    
    npm ERR! UpScore@0.6.0 start: `react-scripts start`
    npm ERR! spawn ENOENT
    
    Error: spawn ENOENT
        at errnoException (child_process.js:1000:11)
        at Process.ChildProcess._handle.onexit (child_process.js:791:34)
    

    This happens because you might have installed react-scripts globally.

    To make this work...

    1. Go to your C:\Users\<USER>\AppData\Roaming
    2. Delete npm and npm-cache directories... (don't worry you can install npm globally later)
    3. Go back to your application directory and remove node_modules folder
    4. Now enter npm install to install the dependencies (delete package-lock.json if its already created)
    5. Now run npm install --save react react-dom react-scripts
    6. Get it started with npm start

    This should get you back on track... Happy Coding

    0 讨论(0)
  • 2020-11-27 11:15

    My issue was stemming from permission issues. I solved mine by following this https://docs.npmjs.com/resolving-eacces-permissions-errors-when-installing-packages-globally

    0 讨论(0)
提交回复
热议问题