reactjs - 无法在 Github 页面上部署新的 create-react-app
问题描述
刚刚完成了一个巨大的应用程序并试图将其部署在 github 上,但它开始抛出 404 错误。我试图创建一个新的,只对 HTML 进行一次更改(只是为了看到它是定制的),它抛出了同样的错误。开发版有效,生产版无效。
这是错误:
DevTools 无法加载 SourceMap:无法加载 chrome-> 扩展的内容://hgmhmanijnjhaffoampdlllchpolkdnj/js/lib/purify.min.js.map:HTTP 错误:状态码
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,语法错误。
这是回购的链接:Github Repo
这是带有脚本的 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"
]
}
}
解决方案
您需要三件事让 CRA 处理 gh-pages
带有 prod 文件的分支(默认为
gh-pages
)✅ 你有那个(我检查过)
启用 gh-pages 的设置,如果不是默认设置,则选择分支并提供服务
root
✅ 你也有,你说
你里面的
homepage
钥匙package.json
❌ 你有
home
而不是homepage
https://create-react-app.dev/docs/deployment#building-for-relative-paths
尝试在你的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"
]
}
}
推荐阅读
- bash - 与 bash 配置文件相关的终端中的错误替换错误
- html - 无序列表元素上的旁白明确说“子弹”
- javascript - onclick 开始动画
- javascript - 如何根据使用脚本从上一个问题中选择的日期更新 Google 表单上的多项选择题
- groovy - Groovy - 将字符串转换为嵌套列表
- r - R中GAM模型中基因组变量的空间自相关
- python - 在使用 skimage 计算 2 个图像之间的度量之前应用掩码
- python - 尝试使用 Python 和 Chromedriver 从网站上抓取数据,但它返回“查找”的非类型错误
- angular - 使用 Visual Studio Code 将简单的 Angular 8 应用程序部署到 Azure
- ios - Apple 是否允许在模拟器上测试身份验证服务(Apple 登录)