将React应用程序部署到GitHub页面时出现问题

时间:2020-08-04 00:02:55

标签: reactjs deployment github-pages

当我尝试将React App部署到GitHub页面时遇到问题,它显示一个空白页面,空白。 在我的GitHub中,我看到了一些文件,但没有看到源文件本身。 我用纱布展开。 这是package.json文件:

  "name": "monsters-relodex",
  "homepage": "https://eliranma.github.io/monster-rolodex",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "@testing-library/jest-dom": "^4.2.4",
    "@testing-library/react": "^9.3.2",
    "@testing-library/user-event": "^7.1.2",
    "gh-pages": "^3.1.0",
    "react": "^16.13.1",
    "react-dom": "^16.13.1",
    "react-scripts": "3.4.1"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject",
    "predeploy": "yarn build",
    "deploy": "gh-pages -b master -d build"

  },
  "eslintConfig": {
    "extends": "react-app"
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  }
}

1 个答案:

答案 0 :(得分:0)

尝试更改

"deploy": "gh-pages -b master -d build"

"deploy": "gh-pages -d build"

如果问题仍然存在,我认为问题是您的master分支上没有实际的源代码。在master分支上提交代码(src文件夹)本身,然后重试。