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

Mac M1芯片VSCode中React项目执行npm start报错:缺失start脚本

解决M1 Mac上VSCode运行React项目时npm start提示"Missing script: 'start'"的问题

报错信息

执行npm start时出现如下错误:

react-app % npm start
npm ERR! Missing script: "start"
npm ERR!
npm ERR! Did you mean one of these?
npm ERR!     npm star # Mark your favorite packages
npm ERR!     npm stars # View packages marked as favorites
npm ERR!
npm ERR! To see a list of scripts, run:
npm ERR!   npm run

日志路径:

npm ERR! A complete log of this run can be found in: /Users/name/.npm/_logs/2023-07-17T13_47_56_576Z-debug-0.log

项目package.json内容

{
  "name": "my-project",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "@testing-library/jest-dom": "^5.16.5",
    "@testing-library/react": "^13.4.0",
    "@testing-library/user-event": "^13.5.0",
    "react": "^18.2.0",
    "react-dom": "^18.2.0",
    "react-scripts": "5.0.1",
    "web-vitals": "^2.1.4"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },
  "eslintConfig": {
    "extends": [
      "react-app",
      "react-app/jest"
    ]
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  }
}

解决方法

  • 确认终端路径是否正确
    报错显示当前路径是react-app,但你的项目根目录是my-project,执行cd my-project切换到正确的项目根目录后,再重新运行npm start。

  • 重置依赖包

    1. 执行rm -rf node_modules package-lock.json
    2. 执行npm install重新安装所有依赖
    3. 再次运行npm start
  • 清空npm缓存
    执行npm cache clean --force清空缓存,之后重新安装依赖并启动项目。

  • 检查react-scripts安装状态
    执行npm list react-scripts查看该包是否存在,若不存在,手动安装:npm install react-scripts@5.0.1 --save

  • M1芯片适配处理
    若上述方法无效,尝试用Rosetta 2运行终端:

    1. 找到「终端」应用,右键选择「显示简介」
    2. 勾选「使用Rosetta打开」
    3. 重启终端,进入项目目录重新执行npm start

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.16 01:55:14