2

I try to deploy my react web app to github pages but when i can't find website online In the console, it says that the app is ready to publish and i should run command npm run deploy but i see the same message every time i run that command Here's package.json file:

{
  "name": "weather-app",
  "version": "0.1.0",
  "private": true,
  "homepage": "http://shotiko-forecast.github.io/weather",
  "dependencies": {
    "react": "^16.12.0",
    "react-dom": "^16.12.0",
    "react-redux": "^7.1.3",
    "react-scripts": "1.1.4",
    "redux": "^4.0.4",
    "redux-thunk": "^2.3.0"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject",
    "predeploy": "npm run build",
    "deploy": "gh-pages -d build"
  },
  "eslintConfig": {
    "extends": "react-app"
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  }
}

command promptgithub pages

9
  • Not sure. It should be https instead of http. Commented Nov 27, 2019 at 19:01
  • Also, have you enabled the public pages in this repository? Commented Nov 27, 2019 at 19:02
  • Shubham, that doesn't work Commented Nov 27, 2019 at 19:03
  • 1
    In the repository configuration, you have to explicitely enable github pages, and there are a few choices on how github should serve the files (gh-pages branch, docs directory, etc) Commented Nov 27, 2019 at 19:10
  • 1
    Possible duplicate of Github pages: Why do I need a gh-pages Commented Nov 27, 2019 at 19:12

2 Answers 2

3
  1. install dependencies to the project.
> npm i gh-pages
  1. In your package.json add script and homepage
"homepage": "https://username.github.io/repo-name",
"scripts": {
    "deploy": "gh-pages -d build"
}
  1. run build Script to build for production
npm run build
  1. run deploy script to deploy your code to the-pages it automatically push on git-hub gh-pages branch and auto-selected on gh-pages branch you can check settings > GitHub pages.
npm run deploy
  1. now it time to check your
https://username.github.io/repo-name
Sign up to request clarification or add additional context in comments.

Comments

0

The name of your React app is weather-app. I assume that the github repository for the app is named as weather-app. There is an error in your package.json file. The homepage property is set incorrectly. It should be set as,

"homepage": "http://<<github-user-name>>.github.io/<<github-repo-name>>"

In your case, change weather to weather-app and everything should work fine

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.