简体   繁体   English

部署到 github 页面的 React 应用程序是空白的

[英]Deployed React app to github pages is blank

I'm following instructions from https://github.com/gitname/react-gh-pages to deploy my react app to github pages.我正在按照https://github.com/gitname/react-gh-pages 的说明将我的 React 应用程序部署到 github 页面。

At the link I'm getting a blank page though and a 404 error: Failed to load resource: the server responded with a status of 404 ()在链接上,我得到了一个空白页和 404 错误: Failed to load resource: the server responded with a status of 404 ()

My app works on local host我的应用程序在本地主机上运行

I searched around and its likely my homepage link that is wrong?我四处搜索,很可能是我的主页链接错误?

link to my repo: https://github.com/PatgioK/pathfindingvisualizer链接到我的仓库: https : //github.com/PatgioK/pathfindingvisualizer

link to the app: https://patgiok.github.io/pathfindingvisualizer/应用程序链接: https : //patgiok.github.io/pathfindingvisualizer/

here is my package.json:这是我的 package.json:

{
  "name": "pathfindingvisualizer",
  "version": "0.1.0",
  "private": true,
  "homepage": "https://patgiok.github.io/pathfindingvisualizer/",
  "dependencies": {
    "@testing-library/jest-dom": "^5.14.1",
    "@testing-library/react": "^11.2.7",
    "@testing-library/user-event": "^12.8.3",
    "gh-pages": "^3.2.3",
    "react": "^17.0.2",
    "react-dom": "^17.0.2",
    "react-scripts": "4.0.3",
    "save-dev": "0.0.1-security",
    "web-vitals": "^1.1.2"
  },
  "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"
  },
  "eslintConfig": {
    "extends": [
      "react-app",
      "react-app/jest"
    ]
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  }
}

Try specifying the branch in the deploy script by adding -b SomeBranchName in your packages.json.尝试通过在 packages.json 中添加-b SomeBranchName来指定部署脚本中的分支。

so:所以:

"scripts": {
    ...,
    "deploy": "gh-pages -d build -b SomeBranchName",
    ...

Where is your static folder in your repo?您的存储库中的static文件夹在哪里? This is what your 404 page is complaining about it.这就是您的 404 页面所抱怨的。 I checked your GitHub repo and I don't see either.我检查了你的 GitHub 存储库,我也没有看到。

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

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