【问题标题】:gh-pages doesn't show my site (don't find index.js)gh-pages 没有显示我的网站(没有找到 index.js)
【发布时间】:2021-12-23 02:19:06
【问题描述】:

这发生在两个项目中: https://nazarenoalt.github.io/curriculum-maker/ https://nazarenoalt.github.io/react-shop/

在这两种情况下,页面为空白,控制台显示:

GET https://nazarenoalt.github.io/index.js net::ERR_ABORTED 404

注意是在根文件夹中寻找 index.js/bundle.js

在这两种情况下 package.json 配置正确

"homepage": "https://nazarenoalt.github.io/curriculum-maker/",

并且两个站点都配置为在gh-pages分支中渲染页面。

作为解决此问题的一种方法,我尝试添加 react-router-dom 的 HashRoute,就像互联网上的某个人说的那样,但它也不起作用。 (在第一页,原来没有使用Router)

【问题讨论】:

  • npm run deploy 会这样做,检查github网站中的设置
  • 我使用npm run deploy进行部署,页面在gh-pages分支中正确收费

标签: reactjs github github-pages


【解决方案1】:

这就是正确的 gh 页面配置的工作原理,

"scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject",
    "predeploy": "npm run build",
    "deploy": "gh-pages -d build"
  },
 "homepage": "http://nazarenoalt.github.io/curriculum-maker/",
 "devDependencies": {
     "gh-pages": "^3.1.0",
     "react-test-renderer": "^17.0.2"
   }

然后运行npm i 然后npm run deploy 将部署网站

【讨论】:

猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2023-02-11
  • 2015-06-04
  • 1970-01-01
  • 2021-10-28
  • 1970-01-01
  • 2021-11-08
  • 2021-12-21
相关资源
最近更新 更多