Create-react-app安装失败,提示“template not found”求解决方案
解决Create React App "template not found" 错误的可行方案
- 直接用指定最新版本的npx命令创建项目,规避全局依赖残留问题:
npx create-react-app@latest my-app # 需要TypeScript模板则用这条 npx create-react-app@latest my-app --template typescript - 彻底清理npm缓存并重置源:
- 强制清理缓存:
npm cache clean --force - 切换到官方npm源(避免镜像源同步延迟导致模板拉取失败):
npm config set registry https://registry.npmjs.org/
- 强制清理缓存:
- 显式指定官方基础模板:
如果默认模板匹配失效,直接指定官方基础模板包:npx create-react-app my-app --template cra-template - 删除本地残留的配置文件:
检查用户根目录下的.npmrc或.yarnrc文件,若有自定义镜像或特殊配置,暂时重命名或删除后重试。 - 手动清除npm缓存目录:
- Windows:删除
%LOCALAPPDATA%\npm-cache文件夹 - Mac/Linux:删除
~/.npm文件夹
完成后重新运行项目创建命令。
- Windows:删除
内容的提问来源于stack exchange,提问作者Afropatricks
相关产品推荐
相关产品推荐

