Home > Back-end >  Unable to host my react app on github. Unable to deploy
Unable to host my react app on github. Unable to deploy

Time:09-26

Pushed the app to GitHub, and completed other procedures like updating the package.json file.

Done with npm install --save gh-pages I think this might have something to do with folders because the react stuff is in 'client' folder and rest node, mongo is in the 'api'.

Still unable to deploy it.

package.json

{
  "name": "mern-todo-api",
  "homepage": "https://ShreyashDo.github.io/Full-stack-react-todo-app",
  "version": "1.0.0",
  "main": "server.js",
  "scripts": {
    "start": "react-scripts start",
    "predeploy": "npm run build",
    "deploy": "gh-pages -d build"
  },
  "author": "Shreyash Dongre",
  "license": "ISC",
  "description": "",
  "dependencies": {
    "cors": "^2.8.5",
    "express": "^4.17.1",
    "gh-pages": "^3.2.3",
    "mongoose": "^6.0.7"
  },
  "devDependencies": {
    "nodemon": "^2.0.12"
  }
}

I referred to https://create-react-app.dev/docs/deployment

Git-repo

Error SS

Folders SS

CodePudding user response:

change your deploy in scripts object in package.json to :

"scripts": {
    "start": "react-scripts start",
    "predeploy": "npm run build",
    "deploy": "cd client && gh-pages -d build",
 },

CodePudding user response:

Seems to be you are not in the right directory. You need to be inside the client folder where the package.json file with object called scripts which has key start, deploy and predeploy is located. You can try this on the terminal.

cd client
  • Related