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

使用npx create-react-app安装React项目时出现FETCH_ERROR报错求助

解决npx create-react-app安装超时问题的方案
  • 切换国内npm镜像源
    官方npm源在国内访问稳定性较差,切换到国内镜像可大幅提升下载效率:

    1. 设置淘宝镜像:npm config set registry https://registry.npmmirror.com
    2. 重新执行项目创建命令:npx create-react-app my-react-app
    3. 若后续需切回官方源,执行:npm config set registry https://registry.npmjs.org
  • 清除npm缓存后重试
    缓存损坏可能导致下载失败,先清理缓存再尝试:

    1. 强制清除缓存:npm cache clean --force
    2. 重新运行创建命令:npx create-react-app my-react-app
  • 手动指定版本并配置代理(若有网络代理)
    若你的网络需通过代理访问外部资源,先配置代理再执行操作:

    1. 设置代理(替换为你的代理地址和端口):
      npm config set proxy http://your-proxy-address:port
      npm config set https-proxy http://your-proxy-address:port
    2. 指定最新版本创建项目:npx create-react-app@latest my-react-app
  • 手动初始化项目并安装依赖
    跳过npx自动安装流程,手动完成项目搭建:

    1. 创建项目目录并进入:mkdir my-react-app && cd my-react-app
    2. 初始化npm项目:npm init -y
    3. 安装核心依赖:npm install react react-dom
    4. 安装react-scripts(提供启动、构建等脚本):npm install --save-dev react-scripts
    5. 在package.json的scripts字段中添加:
      "start": "react-scripts start",
      "build": "react-scripts build",
      "test": "react-scripts test",
      "eject": "react-scripts eject"
      
    6. 最后执行npm start启动项目

内容的提问来源于stack exchange,提问作者M.amanullah behlim

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.08 05:25:20