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

React项目执行npm start报MODULE_NOT_FOUND错误的解决咨询

解决React项目npm start找不到react-scripts模块的问题

针对你遇到的MODULE_NOT_FOUND错误,以下是一系列可行的解决步骤:

  • 彻底清理依赖环境

    1. 删除项目根目录下的node_modules文件夹:
      # Windows系统
      rmdir /s /q node_modules
      # macOS/Linux系统
      rm -rf node_modules
      
    2. 删除package-lock.json和yarn.lock文件:
      rm package-lock.json yarn.lock
      
    3. 清理包管理器缓存:
      # npm
      npm cache clean --force
      # yarn
      yarn cache clean
      
  • 重新安装完整依赖
    执行对应包管理器的安装命令:

    # npm
    npm install
    # yarn
    yarn install
    
  • 精准安装兼容版本的react-scripts
    Node.js 21属于非LTS版本,可能和部分react-scripts版本存在兼容性问题,建议安装稳定兼容的版本:

    npm install --save-exact react-scripts@5.0.1
    
  • 切换到LTS版本的Node.js
    非LTS版本的Node.js可能存在未知兼容性问题,推荐使用LTS版本(如18.x或20.x)。可以通过nvm管理Node.js版本:

    1. 安装nvm后,执行:
      nvm install 20
      nvm use 20
      
    2. 再次执行依赖安装和npm start命令
  • 检查package.json脚本配置
    确认scripts字段中的start命令无误:

    "scripts": {
      "start": "react-scripts start",
      // 其他脚本...
    }
    

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.20 19:29:55