Reactjs React应用程序在Github页面中未正确部署

Reactjs React应用程序在Github页面中未正确部署,reactjs,github-pages,Reactjs,Github Pages,我按照教程将React应用程序部署到github页面。部署时,不会收到任何错误消息,但检查URL时,只会看到一个空白页面(请参阅) 它使用“npm启动”在本地正常运行。无论何时部署,我都只运行“npm run deploy” 我的存储库在这里: 这是我的package.json: { "name": "tallyup-frontend-demo", "version": "0.1.0", "private": true, "dependencies": { "@forta

我按照教程将React应用程序部署到github页面。部署时,不会收到任何错误消息,但检查URL时,只会看到一个空白页面(请参阅)

它使用“npm启动”在本地正常运行。无论何时部署,我都只运行“npm run deploy”

我的存储库在这里:

这是我的package.json:

{
  "name": "tallyup-frontend-demo",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "@fortawesome/fontawesome-svg-core": "^1.2.22",
    "@fortawesome/free-solid-svg-icons": "^5.10.2",
    "@fortawesome/react-fontawesome": "^0.1.4",
    "@types/jest": "24.0.18",
    "@types/lodash": "^4.14.138",
    "@types/node": "12.7.4",
    "@types/react": "16.9.2",
    "@types/react-dom": "16.9.0",
    "@types/react-router-dom": "^4.3.5",
    "bootstrap": "^4.3.1",
    "lodash": "^4.17.15",
    "moment": "^2.24.0",
    "node-fetch": "^2.6.0",
    "react": "^16.9.0",
    "react-bootstrap": "^1.0.0-beta.12",
    "react-dom": "^16.9.0",
    "react-router-dom": "^5.0.1",
    "react-scripts": "3.1.1",
    "typescript": "3.6.2"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject",
    "predeploy": "npm run build",
    "deploy": "gh-pages -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"
    ]
  },
  "homepage": "http://bd21.github.io/tallyup-frontend-demo",
  "devDependencies": {
    "gh-pages": "^2.1.1"
  }
}
当我在Chrome inspector中查看网络呼叫时,我没有看到任何4xx或5xx呼叫。你可以在这里验证

为什么我的应用程序部署/显示不正确

您的站点在Github页面中正常工作

也许问题出在你的react路由器代码上,因为它正在路由一些东西

您的站点在Github页面中正常工作

也许问题出在你的react路由器代码上,因为它正在路由一些东西

当您使用“npm运行部署”时,您没有收到任何错误吗? 因为如果它运行时没有任何错误,«build»目录和«gh pages»分支已创建,那么您可以在«gh pages»分支上轻松更改存储库的分支(对于设置中的github页面),几分钟后,您可以看到自己的github页面

如果您完成了以上所有操作,请检查«build»目录中的index.html。 它应该正确显示React项目的html

另一件我有问题的事情是,您应该为您的存储库添加origin remote(不是其他名称,只是origin): Git远程添加源

希望我能帮助您。

当您使用“npm运行部署”时,您没有收到任何错误吗? 因为如果它运行时没有任何错误,«build»目录和«gh pages»分支已创建,那么您可以在«gh pages»分支上轻松更改存储库的分支(对于设置中的github页面),几分钟后,您可以看到自己的github页面

如果您完成了以上所有操作,请检查«build»目录中的index.html。 它应该正确显示React项目的html

另一件我有问题的事情是,您应该为您的存储库添加origin remote(不是其他名称,只是origin): Git远程添加源

我希望我能帮助你