最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Github Pages and React App not working regardless of methods - Stack Overflow

programmeradmin1浏览0评论

I've been trying to add my React App project to Github Pages for a week. After all the prep work and everything that need to be done, I finally got it to show up, well kinda. It actually doesn't show anything, nor does it give me errors. Which leads me to believe that my script

<script src="../dist/bundle.js"></script>

is the culprit. However, the problem is I've never once used bundle.js. I wanted to learn how to use React without using create-react-app, and in doing so I seem to have gotten to far along in the game I'm not even sure how this is supposed to work.

Here is the Github Pages in it's current form

/

EDIT: It now seems to be showing a 404. I'm not even sure why this is not working at this point. I've tried to many different methods.

I've been trying to add my React App project to Github Pages for a week. After all the prep work and everything that need to be done, I finally got it to show up, well kinda. It actually doesn't show anything, nor does it give me errors. Which leads me to believe that my script

<script src="../dist/bundle.js"></script>

is the culprit. However, the problem is I've never once used bundle.js. I wanted to learn how to use React without using create-react-app, and in doing so I seem to have gotten to far along in the game I'm not even sure how this is supposed to work.

Here is the Github Pages in it's current form

https://kevin6767.github.io/redux-api-opendota2/

EDIT: It now seems to be showing a 404. I'm not even sure why this is not working at this point. I've tried to many different methods.

Share Improve this question asked May 19, 2020 at 19:24 41564156 4001 gold badge5 silver badges17 bronze badges 3
  • First, I think it shouldn't say 404 if index.html file is there. – Ajeet Shah Commented May 19, 2020 at 19:29
  • @ajeetshah in the docs folder github./kevin6767/redux-api-opendota2 – 4156 Commented May 19, 2020 at 19:38
  • This says you have to create a github repository with name: username.github.io where username should be your GitHub username. You should correct your repository name first. – Ajeet Shah Commented May 19, 2020 at 19:49
Add a ment  | 

1 Answer 1

Reset to default 7

I am not sure how you uploaded your React application to GitHub Pages, but, here, I will be mentioning the correct way to do it:

Step 1: Install gh-pages via the terminal, making sure you are in the correct file directory.

$ npm install gh-pages --save -dev (We are saving it as a dev dependency)

Step 2: Go to your package.json and add

"homepage": "<YOUR_GITHUB_USERNAME>.github.io/<REPO_NAME>," above the "name"

Step 3: In the "scripts" section of package.json, add

"predeploy": "npm run build", "deploy": "gh-pages -d build",

Step 4: Assuming that you have already mitted and pushed your code to your Git Repo, now, in the terminal, use the mand npm run deploy to see the changes in your GitHub Pages.

Also, make sure that in your source code, you have set the same route for the homepage as in the package.json.

发布评论

评论列表(0)

  1. 暂无评论