简体   繁体   中英

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

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.

Here is a link to the repo: Github Repo

Here is the package.json with the scripts:

 { "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

  1. A branch with the prod files (default is gh-pages )

    ✅ You have that (I checked)

  2. Settings enabling gh-pages and select the branch if not default and serve from root

    ✅ You have that as well, you say

  3. The homepage key inside your package.json

    ❌ You have home instead of homepage https://create-react-app.dev/docs/deployment#building-for-relative-paths

Try fixing that in your 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"
    ]
  }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM