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

React项目报错:‘react-scripts’未被识别为可执行命令

解决'react-scripts'未被识别的问题
  • 彻底清理依赖后重装
    删除项目根目录下的node_modules文件夹和package-lock.json文件(Windows系统用命令rmdir /s /q node_modules && del package-lock.json,Mac/Linux用rm -rf node_modules package-lock.json),接着执行npm cache clean --force清理缓存,最后运行npm install重新安装所有依赖。

  • 检查package.json配置
    打开项目的package.json,确认scripts字段的命令是否正确:

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

    如果react-scripts没出现在dependencies列表里,执行npm install react-scripts --save手动添加。

  • 用npx直接调用测试
    临时用npx react-scripts start启动项目,如果能正常运行,说明本地依赖可能存在路径问题,可继续用上面的清理重装方法修复。

  • 换源或改用yarn
    要是网络原因导致依赖安装不全,切换到国内npm源:npm config set registry https://registry.npmmirror.com/,再重新装依赖;或者直接改用yarn,执行yarn install后用yarn start启动。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.30 21:15:41