Trying to put React Project on github pages but I get error: npm ERR! Missing script: "deploy"

Viewed 128

Trying to put React Project on Github pages but I get error:

npm ERR! Missing script: "deploy"
npm ERR!
npm ERR! To see a list of scripts, run:
npm ERR!   npm run

npm ERR! A complete log of this run can be found in:

I followed the following steps to try an d put react project on github pages:

Step 1
▶️ git remote add origin [YOUR REPO LINK]
▶️ git add -A
▶️ git commit -m "Initial commit"
▶️ git push -u origin main

Step 2
"homepage": "https://[USERNAME].github.io/[YOUR REPO NAME]",

Step 3
▶️ npm install gh-pages --save-dev

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

▶️ npm run deploy

But when put npm run deploy in terminal I get error anyone know how to fix it? I don't undertand why it says script is missing when I have it in m scripts and have saved the file :

"scripts": {
    "start": "react-scripts start",
    "predeploy": "npm run build",
    "deploy": "gh-pages -d build",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },
1 Answers

you have to update your package.json file.

add those properties "predeploy": "npm run build" and "deploy": "gh-pages -d build" to the existing scripts

enter image description here

Related