简体   繁体   English

将 React 应用程序部署到 GitHub 页时出现问题

[英]Problem when deploying React app to GitHub pages

I have a problem when I try to deploy my react app to GitHub pages, it shows an empty page, blank.当我尝试将我的 React 应用程序部署到 GitHub 个页面时遇到问题,它显示一个空页面,空白。 in my GitHub, I see some files but not the source itself.在我的 GitHub 中,我看到了一些文件,但没有看到源代码本身。 I used yarn to deploy.我用 yarn 来部署。 here is the package.json file:这是 package.json 文件:

  "name": "monsters-relodex",
  "homepage": "https://eliranma.github.io/monster-rolodex",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "@testing-library/jest-dom": "^4.2.4",
    "@testing-library/react": "^9.3.2",
    "@testing-library/user-event": "^7.1.2",
    "gh-pages": "^3.1.0",
    "react": "^16.13.1",
    "react-dom": "^16.13.1",
    "react-scripts": "3.4.1"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject",
    "predeploy": "yarn build",
    "deploy": "gh-pages -b master -d build"

  },
  "eslintConfig": {
    "extends": "react-app"
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  }
}

Try changing尝试改变

this "deploy": "gh-pages -b master -d build"这个"deploy": "gh-pages -b master -d build"

to "deploy": "gh-pages -d build" "deploy": "gh-pages -d build"

if the problem still exists, I think the problem is that you don't have the actual sourcecode on your your master branch.如果问题仍然存在,我认为问题是您的 master 分支上没有实际的源代码。 Commit the code (the src folder) itself on the master branch and try again.在 master 分支上提交代码(src 文件夹),然后重试。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM