Missing Script when I run npm start to create React app

前端 未结 9 1240
北荒
北荒 2021-01-01 18:20

I\'m trying to run the React server by running npm start

When I do this I get a missing script error:

λ npm start
npm ERR! missing scrip         


        
相关标签:
9条回答
  • 2021-01-01 18:33

    This problem has created and still is creating a lot of headaches:

    https://github.com/facebook/create-react-app/issues/8308
    https://github.com/facebook/create-react-app/issues/8086

    Basically the suggestion is correct, may be you have an old version of something around, first try to remove the global create-react-app

    npm uninstall -g create-react-app
    

    Then try to update the npm and all the packages.

    npm install -g npm@latest
    

    Then you can run to create react app again.

    npx create-react-app my-app
    

    This has solved the issue in my case

    0 讨论(0)
  • 2021-01-01 18:35

    global installs of create-react-app are no longer supported.

    do it:

    npm uninstall -g create-react-app

    now do it:

    npm install create-react-app

    now create your app

    npx create-react-app yout-app-name

    0 讨论(0)
  • 2021-01-01 18:35

    Check the names of the scripts in the package.json file, they may be called something different to start. e.g. this part:

    "scripts": {
      "build": "cd packages/react-scripts && node bin/react-scripts.js build",
      "start": "cd packages/react-scripts && node bin/react-scripts.js start",
    },

    Also, try printing your working directory using pwd and check to see if the current directory is correct and run npm run start again.

    0 讨论(0)
  • 2021-01-01 18:40

    I had this problem and managed to fix it by removing the create-react-app with this the npm uninstall -g create-react-app command. This ensured that the npx would always use the latest create-react-app version.

    0 讨论(0)
  • 2021-01-01 18:41

    Installing create-react-app globally is now discouraged. Instead uninstall globally installed create-react-app package by doing: npm uninstall -g create-react-app (you may have to manually delete package folder if this command didn't work for you. Some users have reported they had to delete folders manually)

    Then you can run npx create-react-app my-app to create react app again.

    ref: https://github.com/facebook/create-react-app/issues/8086

    0 讨论(0)
  • 2021-01-01 18:49

    Just in case. From the docs:

    If you've previously installed create-react-app globally via npm install -g create-react-app, we recommend you uninstall the package using npm uninstall -g create-react-app to ensure that npx always uses the latest version.

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