React : deploy build and publish in gh

Create github public repository or push an existing repository from the command line
git remote add origin
git branch -M master
git push -u origin master

Steps to deploy build and publish gh pages for any react projects:

Add in package.json: “homepage”: “"

Open Git bash and execute following commands:
1. npm install gh-pages — save-dev

Skip below two steps if repository already exists
(else it will Reinitialize existing Git repository)
a.git init
b.git remote add origin

2. Add in scripts:
“predeploy”: “npm run build”,
“deploy”: “gh-pages -d build”

3. npm run deploy
if any error, try npm run build
check for error in logs
now run: npm install -g npm@latest

Check your react-script dependency is available or not in package.json
If not available then add manually via:
npm install react-scripts — save

If any other package issues still:
Delete node_modules and package-lock.json
run npm install
run npm run start

Below steps 4. & 5. are not required if your repo is already updated
4. git add .

5. git commit -m “build and deploy”

Now in github, settings-> GitHub Pages ->generate url
change source to ghpages

You Are Done :) Happy to go….

Basic React APP deployed



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Pradeepa Kathiresan

I am open to cross-train and interested in learning new technology.