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

npx create-react-app创建React项目卡在Installing packages阶段

问题说明

执行npx create-react-app my-app创建React项目时,仅能生成包含package.json文件的my-app目录,无其余项目文件,终端输出以下内容后进程停滞:

npx: installed 98 in 135.321s
Creating a new React app in C:\Users\me\Desktop\Projects\react_project\my-app.
Installing packages. This might take a couple of minutes.
Installing react, react-dom, and react-scripts with cra-template...

进程始终卡在Installing packages环节,无后续执行进展。

解决方案

该问题由依赖拉取网络阻塞导致,按以下步骤操作即可修复:

  • 关闭当前卡住的终端窗口,手动删除已经生成的残缺my-app文件夹
  • 打开新的终端窗口,执行命令将npm源切换为国内镜像,解决官方源访问超时问题:
    npm config set registry https://registry.npmmirror.com
  • 执行命令清除npx本地缓存,避免缓存文件异常干扰安装流程:
    npx clear-npx-cache
  • 重新执行项目创建命令:
    npx create-react-app my-app

如果上述操作后仍然出现卡顿,创建项目时可以直接指定镜像参数,强制安装流程走镜像源:
npx create-react-app my-app --registry=https://registry.npmmirror.com

  • 项目创建完成后,若需切回npm官方源,执行以下命令即可:
    npm config set registry https://registry.npmjs.org

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.27 04:09:25