使用Expo构建React Native应用时遭遇NPM 404错误求助
NPM 404 错误:安装 @babel/runtime@7.20.0 失败(Expo React Native 项目)
在使用 Expo 构建 React Native 应用时,遇到以下 NPM 404 错误:
npm ERR! code E404 npm ERR! 404 Not Found - GET https://registry.npmjs.org/@babel%2fruntime - Not found npm ERR! 404 npm ERR! 404 '@babel/runtime@7.20.0' 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.
已尝试以下命令,但问题未解决,依然出现相同的 404 错误:
npm config get registry npm config set registry https://registry.npmjs.org npm install -g expo, npm cache clean --force npm install @babel/runtime@^7.20.0 npm config get proxy, npm install -g npm npm uninstall npm install
解决建议:
- 确认网络环境:关闭代理工具、切换到稳定的网络(如手机热点),避免网络拦截导致无法访问 npm 源
- 检查 npm 源配置:执行
npm config get registry,确保返回值为https://registry.npmjs.org/(注意末尾的斜杠,缺失可能引发请求错误) - 彻底清理依赖后重装:
npm cache clean --force rm -rf node_modules package-lock.json npm install - 验证版本有效性:执行
npm view @babel/runtime versions,查看 7.20.0 是否存在。如果该版本已被移除,更换为存在的版本(如 7.20.1)重新安装 - 检查依赖拼写:确认项目
package.json中@babel/runtime的名称、版本号无拼写错误 - 切换包管理器:尝试使用 yarn 替代 npm 安装依赖:
yarn install - 重置代理配置:执行以下命令清除可能存在的代理干扰:
npm config delete proxy npm config delete https-proxy
内容的提问来源于stack exchange,提问作者The Gamer
相关产品推荐
相关产品推荐

