reactjs 无法获取remote.origin.url(任务必须在git仓库中运行,并配置了origin remote,或者必须配置了“repo”选项

eh57zj3b  于 2023-05-17  发布在  React
关注(0)|答案(1)|浏览(127)

我的React网站有这个问题。我已经在github页面上托管了这个网站,我只是更新了代码并运行了“npm run deploy”,但它一直给我这个错误“Failed to get remote.origin.url(task must be run in a git repository with a configured origin remote or must be configured with the“repo”option).”有什么办法解决这个问题吗?

{
  "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"
sycxhyv7

sycxhyv71#

我在github页面上部署静态react应用程序时也遇到了同样的问题。
下面是我如何通过在终端中放置以下命令来解决它:

git remote add origin  https://github.com/username/repository_name.git

在用户名的地方使用你的用户名

git  add ./                        
git commit -m "comment"

在package.json文件中保留您在部署页面时所做的任何更改。仅仅因为你得到了这个错误,这意味着你已经满足了那里的任何要求。

npm run deploy

Most IMP:我遇到这个问题只是因为当我使用git连接github时
origin1而不是origin。
react应用程序只是在将git远程链接到github时才被部署到origin。

相关问题