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

React项目依赖冲突及react-scripts未识别问题求助

解决npm安装与启动的三个常见问题

1. ERESOLVE peer依赖冲突(react-barcode与react版本不兼容)

react-barcode@1.4.1的peer依赖要求react@^16.0.0 || ^17.0.0,与当前项目的react@18.2.0冲突,可通过以下方式解决:

  • 降级react到17.x版本:
    npm install react@^17.0.2 react-dom@^17.0.2 --save
    
  • 强制忽略peer依赖冲突(注意:可能引发未知兼容问题,谨慎使用):
    npm install --legacy-peer-deps
    
  • 更换支持react@18的替代包,或检查react-barcode是否有更新版本(v2及以上版本通常适配react18)

2. npm全局参数废弃警告

npm已废弃--global、--local参数,需使用--location=global替代。例如全局安装包的命令:
原废弃命令:

npm install -g your-package

替换为:

npm install your-package --location=global

3. 'react-scripts'未识别错误

出现该提示说明react-scripts未安装或未正确关联到项目,解决步骤:

  • 本地安装react-scripts:
    npm install react-scripts --save
    
  • 若为新创建的项目,重新初始化(确保使用最新create-react-app):
    npx create-react-app your-app-name
    cd your-app-name
    
  • 检查package.json的scripts字段,确认start命令配置正确:
    "scripts": {
      "start": "react-scripts start"
    }
    

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.03 06:15:44