You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

部署React应用至GitHub遇权限错误,请求协助解决

解决React应用部署GitHub Pages时的403权限错误

错误原因

你执行npm run deploy时出现的Permission to aneagoie/robofriends.git denied to Moshe844错误,核心问题是你试图将代码推送到不属于你的GitHub仓库(aneagoie/robofriends),自然会被权限拒绝。

解决步骤

1. 检查并修正本地Git远程仓库地址

首先确认本地仓库关联的远程地址是否正确:

git remote -v

如果输出里的origin地址是https://github.com/aneagoie/robofriends.git,立刻修改为你自己的仓库地址:

git remote set-url origin https://github.com/Moshe844/robofriends.git

2. 确认GitHub上已创建对应仓库

确保你在GitHub账号(Moshe844)下已经创建了名为robofriends的仓库,没有的话先去GitHub创建(建议创建公共仓库,私有仓库需要额外配置Pages访问权限)。

3. 确保本地代码已提交

部署前先把本地代码提交到Git仓库:

git add .
git commit -m "prepare for deploy"

4. 重新执行部署命令

现在再运行部署命令:

npm run deploy

5. 排查认证问题(如果仍报错)

如果还是出现403,可能是本地Git保存的GitHub凭据有误:

  • Windows:打开「凭据管理器」→「Windows凭据」,找到对应GitHub的条目删除,重新执行部署时会提示输入账号密码。
  • Mac:在「钥匙串访问」里搜索GitHub相关条目删除,或者执行git config --global credential.helper osxkeychain后重新认证。
  • Linux:修改~/.git-credentials文件,删除旧的GitHub凭据,或者执行git config --global credential.helper store后重新输入。

额外说明

你的package.json配置里,homepage字段https://Moshe844.github.io/robofriends是正确的,对应你自己的GitHub Pages地址,无需修改。deploy脚本的gh-pages -d build也没问题,只要远程仓库正确就能正常推送。

内容的提问来源于stack exchange,提问作者Arye

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.21 23:36:16