[英]React application returning an empty div when deployed on github pages
我一直在努力将我正在开发的网站部署到 github 页面,但部署时它似乎返回了一个空的 div。 当与npx serve build
一起服务时,它可以很好地显示所有信息,并且正常显示在本地主机上,但在部署在 github 页面上时只返回一个空白 div。
我部署的步骤:
下面列出了 package.json 代码,以防其中出现错误
{
"homepage": "https://jonlev03-hub.github.io/media-pilot/",
"name": "media-pilot",
"version": "0.1.0",
"private": true,
"dependencies": {
"@testing-library/jest-dom": "^5.16.4",
"@testing-library/react": "^13.2.0",
"@testing-library/user-event": "^13.5.0",
"gh-pages": "^4.0.0",
"package.json": "^2.0.1",
"react": "^18.1.0",
"react-dom": "^18.1.0",
"react-router-dom": "^6.3.0",
"react-scripts": "^5.0.1",
"web-vitals": "^2.1.4"
},
"scripts": {
"start": "react-scripts start",
"predeploy": "npm run build",
"deploy": "gh-pages -d build",
"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"
]
},
"devDependencies": {
"github-pages": "^0.1.0"
}
}
如果您在该代码块中找不到任何问题,则该站点的所有代码都位于我的存储库 github.com/jonlev03-hub/media-pilot 中。
这是一个与使用我没有指定路由器要使用的 baseurl 有关的问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.