Live Server with NodeJS

The NodeJS live-server package runs a temporary server displaying any HTML/CSS/JS resources in the current folder. It automatically reloads the page in your browser when any of these files change.

  • Verify that Node.js is installed. If you see anything when you run which npm in a terminal, it is. If not, follow the instructions at nodejs.org to install.
  • Install live-server: npm install -g live-server
  • Move your terminal to where your pages live: cd <path-to-content>
  • Start the server: live-server .
  • Open localhost:8080 in a browser.

How to deploy a create react app to Github pages

1. Add homepage

Open your package.json file present inside your react app and add homepage property.

"homepage":"https://yourusername.github.io/repository-name"

replace the above url with your github username and repository name.


2. Install gh-pages

Next, we need to install a package called gh-pages.

npm install --save-dev gh-pages

3. Deploy script

It’s time to add a deploy script commands in our package.json file.

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

Now in your terminal run npm run deploy

4. Setup source to gh-pages branch.

Once you successfully deployed open your GitHub code repository and click on settings tab if you scroll down you can see a GitHub Pages then choose a branch to gh-pages.

That’s it now you can see your react app URL like in the above image.