Ubuntu系统用npx create-expo-app@latest创建项目遇npm包找不到错误
解决Ubuntu 22.04 LTS下
npx create-expo-app@latest找不到expo-template-default@latest的问题 问题重现
执行npx create-expo-app@latest并输入应用名称后,报错:
✖ Something went wrong in downloading and extracting the project files: Could not find npm package "expo-template-default@latest"
Error: Could not find npm package "expo-template-default@latest"
系统环境:
- OS:Ubuntu 22.04 LTS
- Node.js:20.13.1
- npm:10.8.0
解决方案
1. 强制清理npm缓存
缓存损坏可能导致包查找异常,执行以下命令清理后重试:
npm cache clean --force
2. 指定模板稳定版本创建项目
latest标签可能存在同步延迟,改用已发布的稳定模板版本,例如:
npx create-expo-app@latest app1 --template expo-template-default@51.0.1
注:可通过npm view expo-template-default versions查看所有可用版本,选择最新稳定版替换上述版本号
3. 切换npm为官方源
第三方npm源可能同步不及时,检查并切换到官方源:
# 查看当前源 npm config get registry # 切换到官方源 npm config set registry https://registry.npmjs.org/
4. 使用指定版本的create-expo-app
最新版create-expo-app可能与模板版本不兼容,尝试用匹配版本创建:
npx create-expo-app@51.0.1 app1
5. 验证网络连通性
确保网络能正常访问npm registry,执行以下命令测试:
curl https://registry.npmjs.org/expo-template-default/latest
若返回包含版本信息的JSON数据,说明网络正常;若无法访问,检查防火墙或代理设置。
内容的提问来源于stack exchange,提问作者Nana Asare
相关产品推荐
相关产品推荐

