繁体   English   中英

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

[英]Cannot deploy fresh create-react-app on Github Pages

刚刚完成了一个巨大的应用程序并试图将它部署在 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,语法错误。

这是到 repo 的链接: 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

  1. 带有 prod 文件的分支(默认为gh-pages

    ✅ 你有(我检查过)

  2. 设置启用 gh-pages 并选择分支(如果不是默认的)并从root提供服务

    ✅ 你也有,你说

  3. package.jsonhomepage

    ❌ 你有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"
    ]
  }
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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