gpt4 book ai didi

node.js - 无法完成 "npm run deploy"命令以便 React 在 Github Pages 上使用

转载 作者:太空宇宙 更新时间:2023-11-03 23:49:11 25 4
gpt4 key购买 nike

我正在尝试在 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 免费帐户状态有什么关系吗?

最佳答案

对于gh-pages使用版本2.0.1而不是2.2.0

running "gh-pages -d public" hangs on "pushing" per node debug #324

关于node.js - 无法完成 "npm run deploy"命令以便 React 在 Github Pages 上使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59978218/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com