npm start error with create-react-app

后端 未结 20 1857
长发绾君心
长发绾君心 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 10:49

    Author of Create React App checking in.

    You absolutely should not be installing react-scripts globally.
    You also don't need ./node_modules/react-scripts/bin/ in package.json as this answer implies.

    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.

    I suggest doing these three steps:

    1. npm install -g npm@latest to update npm because it is sometimes buggy.
    2. rm -rf node_modules to remove the existing modules.
    3. npm install to re-install the project dependencies.

    This should fix the problem.
    If it doesn't, please file an issue with a link to your project and versions of Node and npm.

    0 讨论(0)
  • 2020-11-27 10:52

    I solve this issue by running following command

    echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p
    

    hope it helps

    0 讨论(0)
  • 2020-11-27 10:53

    It seems like you don't have react-scripts in your global environment. Two possibility are available here :

    npm install -g react-scripts

    or in your package.json change your script part like this :

      "scripts": {
        "start": "./node_modules/react-scripts/bin/react-scripts.js start",
        "start:prod": "pushstate-server build",
        "build": "./node_modules/react-scripts/bin/react-scripts.js build",
        "test": "./node_modules/react-scripts/bin/react-scripts.js test --env=jsdom",
        "eject": "./node_modules/react-scripts/bin/react-scripts.js eject",
        "server": "cd client/api && pm2 start server.js --watch",
        "proxy": "http://128.199.139.144:3000"
      },
    
    0 讨论(0)
  • 2020-11-27 10:55

    This is to help others completely new to react and who area having problems just starting a first app even though they did a fresh install and try using npm install and the other fixes I saw around the forums.

    Running it on Windows 10 with all the latest npm create-react-app installed and got failure after failure on a simple npm start in a simple my-app demo folder.

    Spent a long time with what looks similar to the OP error at first but is slightly different. This starts with ERRNO 4058 and continues with code 'ENOENT' syscall: 'spawn cmd', path: ''cmd' ...

    Eventually worked out from github create-react-app forum that a quick fix for this is registering cmd in the "path" variable. To do this go to System Properties>Environment variables. Click on path variable edit and and add new entry of C:\Windows\System32. Restart CMD prompt and I was good to go.

    0 讨论(0)
  • 2020-11-27 10:56

    For me it was simply that I hadn't added react-scripts to the project so:

    npm i -S react-scripts
    

    If this doesn't work, then rm node_modules as suggested by others

    rm -r node_modules
    npm i
    
    0 讨论(0)
  • 2020-11-27 10:56

    Add .env file with "SKIP_PREFLIGHT_CHECK=true" than npm start

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