我遵循了一个教程,将React应用程序部署到github页面。部署时,没有收到任何错误消息,但是当我检查URL时,只会看到一个空白页(请参见https://bd21.github.io/tallyup-frontend-demo/)。
使用“ npm start”可以在本地正常运行。每当我部署时,我都会运行“ npm run deploy”。
我的存储库在这里:https://github.com/bd21/tallyup-frontend-demo
这是我的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检查器中查看网络通话时,看不到任何4xx或5xx通话。您可以在这里验证。
https://bd21.github.io/tallyup-frontend-demo/
为什么我的应用无法正确部署/显示?
答案 0 :(得分:0)
答案 1 :(得分:0)
使用“ npm run deploy”时,不会收到任何错误消息吗? 如果它运行时没有任何错误,创建了«build»目录和«gh-pages»分支,那么您可以轻松地在«gh-pages»分支上更改存储库的分支(对于设置中的github页面),几分钟后,您可以看到您自己的github页面。
如果执行上述所有操作,请检查«build»目录中的index.html。 它应该正确显示您的React项目的html。
我遇到的另一件事,您应该为存储库添加 origin 远程(不是其他名称,只是 origin ): Git远程添加原点
希望我能帮助您。