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

Windows下npx create-react-app无法完成项目创建的求助

React项目创建卡住:npx create-react-app安装完成后无后续进展

执行npx create-react-app创建React项目时,控制台已输出包安装完成的日志:

Installing packages. This might take a couple of minutes.
Installing react, react-dom, and react-scripts with cra-template...


> core-js@3.32.0 postinstall C:\Users\Prabhat\Sandbox\react\r-app\node_modules\core-js
> node -e "try{require('./postinstall')}catch(e){}"


> core-js-pure@3.32.0 postinstall C:\Users\Prabhat\Sandbox\react\r-app\node_modules\core-js-pure
> node -e "try{require('./postinstall')}catch(e){}"

+ cra-template@1.2.0
+ react-scripts@5.0.1
+ react-dom@18.2.0
+ react@18.2.0
added 1441 packages from 629 contributors in 206.238s

232 packages are looking for funding
  run `npm fund` for details

但进程始终卡在当前状态,无法完成项目创建。已尝试以下方法但未解决:

  • 执行npm uninstall -g create-react-app卸载全局create-react-app,无效;
  • yarn global remove create-react-app,因未使用yarn不适用;
  • 执行npm update npx,此前生效但现在无效。

可行解决方法

1. 强制清除npm缓存

缓存损坏可能导致脚本执行异常,执行以下命令清理缓存:

npm cache clean --force

清理完成后重新执行npx create-react-app my-app。

2. 指定create-react-app最新版本执行

直接指定最新版本绕开版本兼容问题:

npx create-react-app@latest my-app

3. 检查网络环境与npm源

  • 若使用代理,尝试关闭代理后重新执行命令;
  • 切换npm源,可选择官方源或国内可靠镜像:
    切换官方源:
    npm config set registry https://registry.npmjs.org/
    
    切换淘宝镜像源:
    npm config set registry https://registry.npmmirror.com/
    

4. 手动完成项目初始化

既然包已安装完成,可手动进入项目目录验证并启动:

  1. 进入项目文件夹:cd r-app
  2. 启动开发服务器:npm start
    若能正常启动,说明仅create-react-app的收尾脚本卡住,项目可正常使用。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.14 17:55:24