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

执行npm start提示Missing script:start,但package.json已配置对应脚本

解决npm start报错"Missing script: 'start'"的方案
  • 确认当前工作目录
    执行pwd(Mac/Linux)或cd(Windows cmd)查看当前路径,必须确保你在typee项目的根目录(也就是存放package.json的文件夹)下运行npm start。不少人会误进入src之类的子目录,导致npm找不到对应的配置文件。

  • 验证package.json的脚本配置
    打开项目根目录的package.json,检查scripts字段格式是否正确,确保包含:

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

    注意检查拼写(比如有没有把start写成stat)、引号和逗号的JSON语法,任何格式错误都会让npm无法识别脚本。

  • 清除缓存并重装依赖
    先删除本地依赖文件和锁文件:

    # Mac/Linux
    rm -rf node_modules package-lock.json
    # Windows cmd
    rmdir /s node_modules
    del package-lock.json
    # Windows PowerShell
    Remove-Item -Recurse -Force node_modules
    Remove-Item package-lock.json
    

    然后重新安装依赖:

    npm install
    

    依赖安装不完整或缓存异常可能导致脚本无法被正确加载。

  • 检查npm版本兼容性
    执行npm -v查看版本,create-react-app要求npm版本尽量匹配官方推荐的LTS版本(如16.x、18.x)。版本过低的话升级npm:

    npm install -g npm@latest
    
  • 尝试直接启动react-scripts
    在项目根目录执行npx react-scripts start,如果能正常启动,说明npm脚本映射可能有问题。可以先备份原package.json,再执行npm init -y重新初始化npm配置,之后手动补回正确的scripts字段。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.20 00:19:57