简体   繁体   English

无法在 Github 页面上部署新的 create-react-app

[英]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

  1. A branch with the prod files (default is gh-pages )带有 prod 文件的分支(默认为gh-pages

    ✅ You have that (I checked) ✅ 你有(我检查过)

  2. 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 ✅ 你也有,你说

  3. The homepage key inside your package.json package.jsonhomepage

    ❌ 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.

相关问题 无法将 create-react-app 部署到 github-pages - cannot deploy create-react-app to github-pages 使用 create-react-app 将 React 应用程序部署到 github 页面不起作用 - Deploy React app using create-react-app to github pages isn't working 将create-react-app应用程序部署到github页面可以很好地构建,但是不会部署 - deploying create-react-app app to github pages builds fine but won't deploy 如何将 create-react-app 部署到 github 页面? 收到“致命:无法从远程存储库读取”。 - How to deploy create-react-app to github pages? getting "fatal: Could not read from remote repository." 无法使用Create-React-App在github页面中发布我的React App-控制台出现错误 - Cannot publish my react App in github Pages with Create-React-App - got an Error in console create-react-app gh-pages 使用代理部署 - create-react-app gh-pages deploy with proxy Github页面上的Create-React-App返回一个空白页面 - Create-React-App on Github-pages returns a blank page 使用github页面的create-react-app的自定义域 - Custom domain using create-react-app for github pages 如何以root用户身份使用create-react-app更新自定义GitHub Pages - how to update a custom GitHub Pages with create-react-app as root 使用create-react-app + github页面的自定义域名 - Custom domain name with create-react-app + github pages
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM