【发布时间】:2020-05-15 14:35:20
【问题描述】:
我正在尝试在 Github 页面上部署一个网站,该项目是使用 create-react-app 创建的,并安装了 gh-pages 模块。我所有的本地和远程存储库都是最新的,使用npm start 在本地主机上启动页面没有问题。
但是,当我尝试使用 npm run deploy 将此站点部署到 Github Pages 时,它编译成功,但随后在 gh-pages -d build 命令上永远挂起。它永远持续下去,并且不会自行退出并显示错误消息,也不会创建错误日志。我想这个命令可能需要很长时间才能完成,但我等了 30 分钟没有结束,所以我不确定。
下面是我的 package.json:
{
"name": "website",
"version": "0.1.0",
"private": true,
"homepage": "https://xxx.github.io/website",
"dependencies": {
"@testing-library/jest-dom": "^4.2.4",
"@testing-library/react": "^9.4.0",
"@testing-library/user-event": "^7.2.1",
"gh-pages": "^2.2.0",
"react": "^16.12.0",
"react-dom": "^16.12.0",
"react-scripts": "3.3.0"
},
"scripts": {
"start": "react-scripts start",
"predeploy": "npm run build",
"deploy": "gh-pages -d build",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"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"
]
}
}
这是npm run deploy 强制终止后我的shell 日志:
> website@0.1.0 predeploy C:\Users\user\directory
> npm run build
> website@0.1.0 build C:\Users\user\directory
> react-scripts build
Creating an optimized production build...
Compiled successfully.
File sizes after gzip:
40.32 KB build\static\js\2.08db1231.chunk.js
2.9 KB build\static\js\main.0c674757.chunk.js
784 B build\static\js\runtime-main.e77b87bb.js
547 B build\static\css\main.d1b05096.chunk.css
The project was built assuming it is hosted at /website/.
You can control this with the homepage field in your package.json.
The build folder is ready to be deployed.
To publish it at https://xxx.github.io/website , run:
npm run deploy
Find out more about deployment here:
bit.ly/CRA-deploy
> website@0.1.0 deploy C:\Users\user\directory
> gh-pages -d build
顺便说一句,我的 github 免费帐户状态与什么有关吗?
【问题讨论】:
标签: node.js reactjs git npm github-pages