通过Expo安装React Native时遭遇npm E404错误求助
npm ERR! code E404
npm ERR! 404 Not Found - GET https://skimdb.npmjs.com/registry/create-expo-app/-/create-expo-app-2.1.1.tgz - not_found
npm ERR! 404
npm ERR! 404 'create-expo-app@https://skimdb.npmjs.com/registry/create-expo-app/-/create-expo-app-2.1.1.tgz' is not in this registry.
npm ERR! 404
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.
这个错误的核心原因是你的npm当前指向的registry是skimdb.npmjs.com,这个源已经无法正常提供create-expo-app@2.1.1的包资源,需要切换到官方npm源。
解决步骤:
先检查当前npm registry配置:
npm config get registry如果返回的是
https://skimdb.npmjs.com/registry/,说明确实是源的问题。将npm registry切换为官方源:
npm config set registry https://registry.npmjs.org/清空npm缓存,避免残留的错误缓存影响安装:
npm cache clean --force重新执行Expo项目创建命令,推荐使用
latest标签获取最新版本,避免指定旧版本出现找不到的情况:npx create-expo-app@latest 你的项目名称
临时方案(不想修改全局配置的话)
可以在安装时临时指定官方源:
npx --registry https://registry.npmjs.org create-expo-app@latest 你的项目名称
如果你使用Yarn
同样检查并修改Yarn的registry:
yarn config get registry yarn config set registry https://registry.npmjs.org/
内容的提问来源于stack exchange,提问作者shadrac

