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

使用npx create-react-app创建React应用遇6个漏洞,npm start无法启动求助

解决npx create-react-app创建应用失败及启动异常的方案

1. 彻底清理残留依赖

  • 全局卸载所有相关包:
    npm uninstall -g create-react-app
    yarn global remove create-react-app
    
  • 清理npm缓存:
    npm cache clean --force
    
  • 清理npx缓存:
    • Windows:删除%USERPROFILE%\.npm\_npx目录
    • macOS/Linux:删除~/.npm/_npx目录

2. 指定最新版本创建项目

绕过缓存直接拉取最新稳定版的create-react-app创建应用:

npx create-react-app@latest my-app

3. 修复项目依赖漏洞

进入项目目录后,执行命令修复漏洞:

cd my-app
npm audit fix --force

若上述命令无效,手动更新package.json里的相关依赖到最新稳定版,再执行npm install重新安装。

4. 改用Vite构建项目

如果create-react-app的问题仍无法解决,换用更轻量的Vite工具创建React项目:

npm create vite@latest my-app -- --template react
cd my-app
npm install
npm run dev

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.18 22:37:37