【发布时间】:2021-06-27 17:23:44
【问题描述】:
我正在尝试将我的反应站点发布到 github 页面。(URL:https://kumarsreenivas051.github.io/kumar-site/)
我将代码直接提交到 Github 中的 master 分支。
我的 package.json 包含:
{
"name": "kumar-site",
"version": "0.1.0",
"private": true,
"dependencies": {
"@material-ui/core": "^4.11.4",
"@material-ui/icons": "^4.11.2",
"@testing-library/jest-dom": "^5.11.10",
"@testing-library/react": "^11.2.6",
"@testing-library/user-event": "^12.8.3",
"gh-pages": "^2.2.0",
"react": "^17.0.2",
"react-bootstrap-validation": "^0.1.11",
"react-dom": "^17.0.2",
"react-scripts": "4.0.3",
"web-vitals": "^1.1.1"
},
"scripts": {
"predeploy": "npm run build",
"deploy": "gh-pages -d build",
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"homepage": "https://kumarsreenivas051.github.io/kumar-site"
}
当我尝试运行gh-pages -d build
出现错误。日志显示:
14 verbose lifecycle kumar-site@0.1.0~deploy: CWD: C:\Users\Kumaraswamy V S\Documents\GitHub\kumarsreenivas051.github.io\kumar-site
15 silly lifecycle kumar-site@0.1.0~deploy: Args: [ '/d /s /c', 'gh-pages -d build' ]
16 silly lifecycle kumar-site@0.1.0~deploy: Returned: code: 1 signal: null
17 info lifecycle kumar-site@0.1.0~deploy: Failed to exec deploy script
18 verbose stack Error: kumar-site@0.1.0 deploy: `gh-pages -d build`
18 verbose stack Exit status 1
18 verbose stack at EventEmitter.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\index.js:332:16)
18 verbose stack at EventEmitter.emit (events.js:315:20)
18 verbose stack at ChildProcess.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\lib\spawn.js:55:14)
18 verbose stack at ChildProcess.emit (events.js:315:20)
18 verbose stack at maybeClose (internal/child_process.js:1048:16)
18 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:288:5)
19 verbose pkgid kumar-site@0.1.0
20 verbose cwd C:\Users\Kumaraswamy V S\Documents\GitHub\kumarsreenivas051.github.io\kumar-site
21 verbose Windows_NT 10.0.19043
22 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "deploy"
23 verbose node v14.16.0
24 verbose npm v6.14.11
25 error code ELIFECYCLE
26 error errno 1
27 error kumar-site@0.1.0 deploy: `gh-pages -d build`
27 error Exit status 1
28 error Failed at the kumar-site@0.1.0 deploy script.
28 error This is probably not a problem with npm. There is likely additional logging output above.
29 verbose exit [ 1, true ]
我该怎么做才能成功发布站点?
仅供参考:使用的操作系统是 Windows 10 64 位
【问题讨论】: