You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

安装React后执行npm start报错:npm ERR! missing script: start

Fixing "npm ERR! missing script: start" in React Projects

Hey there, let’s get that annoying error sorted out so you can launch your React app. This is one of the most common hiccups when starting out with React, and here are the step-by-step fixes that usually resolve it:

  • Double-check your working directory
    First off, make sure you’re running npm start from the root folder of your React project. If you created your app with npx create-react-app my-app, you need to cd my-app first before running the start command. Use pwd (Mac/Linux) or cd (Windows) to confirm you’re in the right place—you should see the package.json file in this folder.

  • Verify the start script exists in package.json
    Open up your project’s package.json file and look for the scripts section. A standard React app should have this line:

    "scripts": {
      "start": "react-scripts start",
      "build": "react-scripts build",
      "test": "react-scripts test",
      "eject": "react-scripts eject"
    }
    

    If the start line is missing, add it manually and save the file. This is often the case if the project initialization was interrupted or you set up the project manually instead of using create-react-app.

  • Reinstall your dependencies
    Sometimes corrupted node modules or lock files cause this issue. Try these steps:

    1. Delete the node_modules folder and package-lock.json (or yarn.lock if you use Yarn)
    2. Run npm install to reinstall all dependencies fresh
      Here are the commands for different systems:
    # Mac/Linux
    rm -rf node_modules package-lock.json
    npm install
    
    # Windows (Command Prompt)
    rmdir /s /q node_modules
    del package-lock.json
    npm install
    
  • Ensure your React project was created correctly
    If you didn’t use create-react-app to set up your project, you might not have the pre-configured start script. In this case, either:

    • Use npx create-react-app my-new-app to generate a standard React project with all necessary scripts, or
    • Configure the start script yourself (you’ll need to set up a bundler like Webpack and a dev server manually, which is more advanced)
  • Try running the script directly with npx
    If all else fails, skip the npm script and run the React dev server directly:

    npx react-scripts start
    

    You can also try updating your npm version to the latest with npm install -g npm@latest to rule out any version-related bugs.

内容的提问来源于stack exchange,提问作者Gagandeep

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.06 11:02:35