我的反应网站有这个问题。我已经在 github 页面上托管了这个网站,我刚刚更新了代码并运行了“npm run deploy”,但它一直给我这个错误“无法获取 remote.origin.url(任务必须在 git 存储库中运行使用已配置的源远程或必须使用“repo”选项进行配置)。”知道如何解决这个问题吗?
{
"homepage": "https://saksham-89.github.io/Portfolio",
"name": "portfolio",
"version": "2",
"dependencies": {
"@emailjs/browser": "^3.4.0",
"@iconscout/react-unicons": "^1.1.6",
"@testing-library/jest-dom": "^5.14.1",
"@testing-library/react": "^12.0.0",
"@testing-library/user-event": "^13.2.1",
"framer-motion": "^6.2.8",
"git": "^0.1.5",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-scripts": "5.0.0",
"react-scroll": "^1.8.6",
"swiper": "^8.0.7",
"web-vitals": "^2.1.0",
"yarn": "^1.22.19"
},
"scripts": {
"predeploy": "npm run build",
"deploy": "gh-pages -d build",
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
我在 github 页面上部署静态反应应用程序时也遇到了同样的问题。
这是我通过在终端中输入以下命令来解决它的方法:
1 -> git 远程添加来源https://github.com/username/repository_name.git
在用户名处使用您的用户名
2 -> git 添加 ./
3 -> git commit -m “评论”
保留在 package.json 文件中部署页面时所做的任何更改。仅仅因为您收到此错误,就意味着您已经满足了任何要求。
4 -> npm 运行部署
大多数IMP :
我遇到这个问题只是因为在将 github 与 git 链接时我正在使用
origin1 而不是 origin .
React 应用程序仅在将 git 与 github 远程链接时为 origin 部署。