简体   繁体   中英

React app didn't render correctly when I deployed it to github pages

I try to deploy my react app to github pages, but it seems that it didn't work properly. I got a blank page when I tried to visit it by link. Anybody knows solutions? Thank you for your help!

My code is like: package.json

  "homepage": "https://yunxiuqiu1115.github.io/food-ordering-site",
  "scripts": {
    "start": "PORT=3006 react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject",
    "predeploy": "npm run build",
    "deploy": "gh-pages -d build"
  },

I ran npm run deploy and get the successful outcome.

Everything works well locally, but does not work in github pages. Hope that anyone can help! Thanks!

We need to install GitHub Pages package as a dev-dependency .

cd **
npm install gh-pages --save-dev

Add properties to package.json file.

Follow this for more details https://dev.to/yuribenjamin/how-to-deploy-react-app-in-github-pages-2a1f

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM