当我将其部署到github页面时,React应用无法正确呈现

问题描述

我尝试将我的react应用程序部署到github页面,但似乎无法正常工作。当我尝试通过链接访问它时,我得到一个空白页。有人知道解决方案吗?谢谢您的帮助!

我的代码如下: 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"
  },

我跑了npm run deploy并获得了成功的结果。

一切都在本地运行良好,但在github页面中不起作用。希望任何人都能提供帮助!谢谢!

解决方法

我们需要将GitHub Pages软件包安装为 dev-dependency

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

将属性添加到package.json文件。

关注此详细信息https://dev.to/yuribenjamin/how-to-deploy-react-app-in-github-pages-2a1f