[英]Cannot deploy fresh create-react-app on Github Pages
just finished a huge app and tried to deploy it on github but it started throwing 404 errors.刚刚完成了一个巨大的应用程序并试图将它部署在 github 上,但它开始抛出 404 错误。 I tried to create a fresh new one with just one change in the HTML (just to see that is customized) and it's throwing the same error.
我试图用 HTML 中的一个更改创建一个新的(只是为了看到它是自定义的),但它抛出了同样的错误。 The dev version works, the production not.
开发版有效,生产版无效。
Here is the error:这是错误:
DevTools failed to load SourceMap: Could not load content for chrome-> extension://hgmhmanijnjhaffoampdlllchpolkdnj/js/lib/purify.min.js.map: HTTP error: status code
DevTools 无法加载 SourceMap:无法加载 chrome-> 扩展的内容://hgmhmanijnjhaffoampdlllchpolkdnj/js/lib/purify.min.js.map:HTTP 错误:状态代码
404, net::ERR_UNKNOWN_URL_SCHEME favicon.ico:1 GET https://kirilchristov.github.io/favicon.ico 404 manifest.json:1 GET https://kirilchristov.github.io/manifest.json 404 manifest.json:1 Manifest: Line: 1, column: 1, Syntax error.
404, net::ERR_UNKNOWN_URL_SCHEME favicon.ico:1 获取https://kirilchristov.github.io/favicon.ico 404 manifest.json:1 获取https://kirilchristov.github.io/manifest.json 404 manifest.json: 1 清单:行:1,列:1,语法错误。
Here is a link to the repo: Github Repo这是到 repo 的链接: Github Repo
Here is the package.json with the scripts:这是带有脚本的 package.json:
{ "home":"https://kirilchristov.github.io/renker", "name": "gr", "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", "react": "^16.13.1", "react-dom": "^16.13.1", "react-scripts": "3.4.3" }, "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" }, "browserslist": { "production": [ ">0.2%", "not dead", "not op_mini all" ], "development": [ "last 1 chrome version", "last 1 firefox version", "last 1 safari version" ] } }
You need three things for CRA to work on gh-pages CRA 需要做三件事才能处理 gh-pages
A branch with the prod files (default is gh-pages
)带有 prod 文件的分支(默认为
gh-pages
)
✅ You have that (I checked) ✅ 你有(我检查过)
Settings enabling gh-pages and select the branch if not default and serve from root
设置启用 gh-pages 并选择分支(如果不是默认的)并从
root
提供服务
✅ You have that as well, you say ✅ 你也有,你说
The homepage
key inside your package.json
package.json
的homepage
键
❌ You have home
instead of homepage
https://create-react-app.dev/docs/deployment#building-for-relative-paths ❌ 你有
home
而不是homepage
https://create-react-app.dev/docs/deployment#building-for-relative-paths
Try fixing that in your package.json
尝试在您的
package.json
修复它
{
"homepage":"https://kirilchristov.github.io/renker",
"name": "gr",
"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",
"react": "^16.13.1",
"react-dom": "^16.13.1",
"react-scripts": "3.4.3"
},
"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"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.