Expo项目中无法安装@react-native-google-signin/google-signin@latest的问题
安装@react-native-google-signin/google-signin时出现403权限错误的解决办法
我按照官方文档安装谷歌登录包@react-native-google-signin/google-signin,但执行安装命令时触发403权限拒绝错误。
我的.npmrc配置如下:
//npm.pkg.github.com/:_authToken=${AUTH_TOKEN} @react-native-google-signin:registry=https://npm.pkg.github.com/
执行命令 npm i @react-native-google-signin/google-signin@latest 时,出现以下错误:
npm ERR! code E403 npm ERR! 403 403 Forbidden - GET https://npm.pkg.github.com/@react-native-google-signin%2fgoogle-signin - Permission permission_denied: read_package npm ERR! 403 In most cases, you or one of your dependencies are requesting npm ERR! 403 a package version that is forbidden by your security policy, or npm ERR! 403 on a server you do not have access to.
完整日志路径:C:\npm-cache_logs\2025-02-19T20_40_18_317Z-debug-0.log
解决步骤:
- 检查令牌权限:确保GitHub个人访问令牌(AUTH_TOKEN)开启了
read:packages权限。生成令牌时必须勾选该选项,否则无法读取GitHub Packages中的包。 - 验证环境变量:确认
AUTH_TOKEN环境变量已正确配置,或者直接在.npmrc中把${AUTH_TOKEN}替换为实际令牌值(注意不要公开泄露令牌)。 - 确认包访问权限:检查你的GitHub账号是否有权限访问
@react-native-google-signin/google-signin包。如果是私有包,需确保账号已被添加到对应仓库的权限列表。 - 尝试切换npm源:若该包已发布到npm官方仓库,可移除
.npmrc中@react-native-google-signin的registry配置,直接执行安装命令,从官方源拉取包。 - 清理npm缓存:执行
npm cache clean --force清理缓存后,重新运行安装命令。
内容的提问来源于stack exchange,提问作者Dhanny Phantom
相关产品推荐
相关产品推荐

