# Struggling to deploy react app on GitHub

**URL:** <https://forum.freecodecamp.org/t/struggling-to-deploy-react-app-on-github/237911>\
**Category:** General\
**Created:** [November 4, 2018, 2:06am UTC](https://forum.freecodecamp.org/t/struggling-to-deploy-react-app-on-github/237911 "2018-11-04T02:06:48Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gilbert1391](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/gilbert1391/32/93761_2.png) [@Gilbert1391](https://forum.freecodecamp.org/u/Gilbert1391)\
**Post date:** [November 4, 2018, 2:06am UTC](https://forum.freecodecamp.org/t/struggling-to-deploy-react-app-on-github/237911/1 "2018-11-04T02:06:48Z")

</div>

Well this is very annoying, I am trying to deploy my first React app built with create-react-app, I googled about how to do this and it looks like I’m missing something, I am following the commands shown in the terminal, but nothing works. I go to youtube but everyone seems to be skipping a step.

Now I am not a git expert but at least I know how to deploy a static site on GitHub, how can I deploy this app?

These are the steps I followed:

- Added these scripts to my package.json file:

```auto
"homepage": "http://Gilbert1391.github.io/dashboardbox"

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

```

2- `npm run build` and the build folder is created successfully in the root folder of my repo.

3- Terminal says to run `npm run deploy`, I do and then this happens:

 ![55%20PM](https://global.discourse-cdn.com/freecodecamp/original/3X/8/e/8e59cc2e47da8266585b2534f3eaac75e08a7717.png)

The site is actually showing 404 not found [https://gilbert1391.github.io/dashboardbox/](https://gilbert1391.github.io/dashboardbox/)

Can I get some help here? Thanks.

Btw, why after I run `npm run build` and the build folder with all its files is created, then i run `git status` I don’t see any changes in the terminal?, it says the branch is up to date but what about this new folder that isn’t registered?

---

<div class="post-metadata">

**Author:** ![Gilbert1391](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/gilbert1391/32/93761_2.png) [@Gilbert1391](https://forum.freecodecamp.org/u/Gilbert1391)\
**Post date:** [November 4, 2018, 2:29am UTC](https://forum.freecodecamp.org/t/struggling-to-deploy-react-app-on-github/237911/2 "2018-11-04T02:29:09Z")

</div>

I keep digging, read somewhere to run this command `npm install --save-dev gh-pages`, this added a devDependencies to my package.json

```auto
"devDependencies": {
    "gh-pages": "^2.0.1"
  }

```

But now when I run `npm run build` I get an error.

 ![41%20PM](https://global.discourse-cdn.com/freecodecamp/original/3X/a/5/a50a9f4a146d8c29eda65930e893b10c79e555c9.png)

---

<div class="post-metadata">

**Author:** ![WebDevCoach](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/webdevcoach/32/101360_2.png) [@WebDevCoach](https://forum.freecodecamp.org/u/WebDevCoach)\
**Post date:** [November 4, 2018, 3:18am UTC](https://forum.freecodecamp.org/t/struggling-to-deploy-react-app-on-github/237911/3 "2018-11-04T03:18:57Z")

</div>

Hey @Gilbert1391. Do you specifically need to deploy the application to GitHub. I created a video detailing how I deployed my Random Quote Machine to Netlify. It’s pretty easy. Hope it helps.

---

<div class="post-metadata">

**Author:** ![kevinSmith](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/kevinsmith/32/72934_2.png) [@kevinSmith](https://forum.freecodecamp.org/u/kevinSmith)\
**Post date:** [November 4, 2018, 3:51am UTC](https://forum.freecodecamp.org/t/struggling-to-deploy-react-app-on-github/237911/4 "2018-11-04T03:51:46Z")

</div>

I don’t know, I just created a build and manually moved my files to the github pages.

---

<div class="post-metadata">

**Author:** ![Gilbert1391](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/gilbert1391/32/93761_2.png) [@Gilbert1391](https://forum.freecodecamp.org/u/Gilbert1391)\
**Post date:** [November 4, 2018, 3:53am UTC](https://forum.freecodecamp.org/t/struggling-to-deploy-react-app-on-github/237911/5 "2018-11-04T03:53:45Z")

</div>

You mean you run `npm run build` take that folder and create a new repo, push the files to GitHub and deploy it as a regular static site?

---

<div class="post-metadata">

**Author:** ![Gilbert1391](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/gilbert1391/32/93761_2.png) [@Gilbert1391](https://forum.freecodecamp.org/u/Gilbert1391)\
**Post date:** [November 4, 2018, 3:55am UTC](https://forum.freecodecamp.org/t/struggling-to-deploy-react-app-on-github/237911/6 "2018-11-04T03:55:33Z")

</div>

Well this actually worked! Jesus Christ I was getting frustrated already trying to find a solution to this, thank you very much.

---

<div class="post-metadata">

**Author:** ![kevinSmith](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/kevinsmith/32/72934_2.png) [@kevinSmith](https://forum.freecodecamp.org/u/kevinSmith)\
**Post date:** [November 4, 2018, 3:56am UTC](https://forum.freecodecamp.org/t/struggling-to-deploy-react-app-on-github/237911/7 "2018-11-04T03:56:41Z")

</div>

I created the github pages site (the special repo for that) and pushed them there to “deploy” them. If you haven’t already, read up on github pages.

---

<div class="post-metadata">

**Author:** ![kevinSmith](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/kevinsmith/32/72934_2.png) [@kevinSmith](https://forum.freecodecamp.org/u/kevinSmith)\
**Post date:** [November 4, 2018, 3:57am UTC](https://forum.freecodecamp.org/t/struggling-to-deploy-react-app-on-github/237911/8 "2018-11-04T03:57:07Z")

</div>

Yes, with those that static site bundle.

---

<div class="post-metadata">

**Author:** ![Gilbert1391](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/gilbert1391/32/93761_2.png) [@Gilbert1391](https://forum.freecodecamp.org/u/Gilbert1391)\
**Post date:** [November 4, 2018, 3:59am UTC](https://forum.freecodecamp.org/t/struggling-to-deploy-react-app-on-github/237911/9 "2018-11-04T03:59:58Z")

</div>

Umm github pages site? I don’t know anything about that, so far until I know i’ve been deploying static sites with the usual git flow:

create new repo on GitHub

```auto
git init repo
git add .
git commi -m "first commit"
//...etc

```

---

<div class="post-metadata">

**Author:** ![kevinSmith](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/kevinsmith/32/72934_2.png) [@kevinSmith](https://forum.freecodecamp.org/u/kevinSmith)\
**Post date:** [November 4, 2018, 5:47am UTC](https://forum.freecodecamp.org/t/struggling-to-deploy-react-app-on-github/237911/10 "2018-11-04T05:47:07Z")

</div>

Github itself isn’t deploying a site, per se. It is creating a public repo, so people can see your code. You can’t “run” the code. For that you need a hosting site. Github will do static hosting for you, through their [github pages](https://pages.github.com/). I assumed that what you were trying to do was a CRA automated way of doing that. I just did it the manual way - creating the github pages repo and pushing my build bundle there.

---

<div class="post-metadata">

**Author:** ![Layer](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/layer/32/82898_2.png) [@Layer](https://forum.freecodecamp.org/u/Layer)\
**Post date:** [November 4, 2018, 9:02am UTC](https://forum.freecodecamp.org/t/struggling-to-deploy-react-app-on-github/237911/11 "2018-11-04T09:02:54Z")

</div>

^^  
[GitHub - Deploying a React App (created using create-react-app) to GitHub Pages](https://github.com/gitname/react-gh-pages)

---

<div class="post-metadata">

**Author:** ![Gilbert1391](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/gilbert1391/32/93761_2.png) [@Gilbert1391](https://forum.freecodecamp.org/u/Gilbert1391)\
**Post date:** [November 4, 2018, 7:10pm UTC](https://forum.freecodecamp.org/t/struggling-to-deploy-react-app-on-github/237911/12 "2018-11-04T19:10:57Z")

</div>

I wish I had found this guide before struggling so much, thanks. I’ll keep it in mind for the next project.

---

<div class="post-metadata">

**Author:** ![kevinSmith](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/kevinsmith/32/72934_2.png) [@kevinSmith](https://forum.freecodecamp.org/u/kevinSmith)\
**Post date:** [November 4, 2018, 7:18pm UTC](https://forum.freecodecamp.org/t/struggling-to-deploy-react-app-on-github/237911/13 "2018-11-04T19:18:34Z")

</div>

I still say it would be better to simply learn how to do a CRA build and how github pages works. Eventually you are going to have to deploy an app somewhere else and you won’t have scripts to do it for you. And eventually you may want to push something besides a CRA to github pages and things are going to get complicated.

Really, learning how to create a repo for the github pages and pushing to it is simple. The only other thing you need to understand is the CRA build process, which is not that complicated and you need to understand anyway. Personally, I find these scripts more complicated than simply _doing_ it.

---

<div class="post-metadata">

**Author:** ![Gilbert1391](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/gilbert1391/32/93761_2.png) [@Gilbert1391](https://forum.freecodecamp.org/u/Gilbert1391)\
**Post date:** [November 4, 2018, 7:26pm UTC](https://forum.freecodecamp.org/t/struggling-to-deploy-react-app-on-github/237911/14 "2018-11-04T19:26:15Z")

</div>

Yes I will also try your method as well, in fact it does sound a easier actually, it seems like just deploying a site like the others static sites I have deployed in the past using GitHub. I mean by your comment I take it like that’s exactly what it is. Just get the build folder from CRA, create a repo and push the files to that repo, go to settings and select master branch, done. Your site is now live.

Last night I was just tired and eager to deploy my app, so I followed the first tutorial I found and got errors.

---

<div class="post-metadata">

**Author:** ![kevinSmith](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/kevinsmith/32/72934_2.png) [@kevinSmith](https://forum.freecodecamp.org/u/kevinSmith)\
**Post date:** [November 4, 2018, 7:54pm UTC](https://forum.freecodecamp.org/t/struggling-to-deploy-react-app-on-github/237911/15 "2018-11-04T19:54:27Z")

</div>

> [@Gilbert1391](#):
>
> Just get the build folder from CRA, create a repo and push the files to that repo

Basically, it just needs to have the specific name that github wants for its gihub pages. I think it has to be “_[username].github.io_”. I don’t think there are other requirements - check the github docs. I had to do it this way because I was hosting my portfolio app on github and that was written in jQuery but I had sample React apps in folders. I don’t know how the other method handles anything but a simple React app.

---

<div class="post-metadata">

**Author:** ![ILM](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/ilm/32/363239_2.png) [@ILM](https://forum.freecodecamp.org/u/ILM)\
**Post date:** [January 16, 2021, 11:34am UTC](https://forum.freecodecamp.org/t/struggling-to-deploy-react-app-on-github/237911/16 "2021-01-16T11:34:37Z")

</div>

Closed on January 16, 2021, 11:34am UTC


