我正在学习React,所以我做了一个巩固我学到的东西的项目,现在我完成了我想将它托管在github页面上的工作,我知道这将与我所做的标准项目以及我如何设置github的方式不同。直到现在为止的页面,并且因为我之前从未做过,所以我搜索了如何做,并找到了一些教程和文档,我一直在关注它们。
但是不是托管应用程序,而是在实际的github页面上显示的是README文件,并且脚本没有像我应该做的那样在我的仓库中创建新的gh-pages分支
这是终端机中的错误
> react-recipe-api@0.1.0 predeploy D:\Documents\Git-repo\finished\react-recipe-api
> npm run build
> react-recipe-api@0.1.0 build D:\Documents\Git-repo\finished\react-recipe-api
> react-scripts build
Creating an optimized production build...
Compiled successfully.
File sizes after gzip:
50.79 KB build\static\js\2.56be15e5.chunk.js
1.55 KB build\static\js\main.5045ac4c.chunk.js
785 B build\static\js\runtime-main.781931a1.js
775 B build\static\css\main.f7628ea1.chunk.css
The project was built assuming it is hosted at /react-recipe-finder/.
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://nicoding0.github.io/react-recipe-finder , run:
npm run deploy
Find out more about deployment here:
hxxps://bitly/CRA-deploy
> react-recipe-api@0.1.0 deploy D:\Documents\Git-repo\finished\react-recipe-api
> gh-pages -d build
events.js:187
throw er; // Unhandled 'error' event
^
Error: spawn git ENOENT
←[90m at Process.ChildProcess._handle.onexit (internal/child_process.js:264:19)←[39m
←[90m at onErrorNT (internal/child_process.js:456:16)←[39m
←[90m at processTicksAndRejections (internal/process/task_queues.js:80:21)←[39m
Emitted 'error' event on ChildProcess instance at:
←[90m at Process.ChildProcess._handle.onexit (internal/child_process.js:270:12)←[39m
←[90m at onErrorNT (internal/child_process.js:456:16)←[39m
←[90m at processTicksAndRejections (internal/process/task_queues.js:80:21)←[39m {
errno: ←[32m'ENOENT'←[39m,
code: ←[32m'ENOENT'←[39m,
syscall: ←[32m'spawn git'←[39m,
path: ←[32m'git'←[39m,
spawnargs: [ ←[32m'config'←[39m, ←[32m'user.name'←[39m ]
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! react-recipe-api@0.1.0 deploy: `gh-pages -d build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the react-recipe-api@0.1.0 deploy script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\scorpio\AppData\Roaming\npm-cache\_logs\2019-12-13T13_45_56_265Z-debug.log
以下是日志文件的内容:
0 info it worked if it ends with ok
1 verbose cli [
1 verbose cli 'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli 'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli 'run',
1 verbose cli 'deploy'
1 verbose cli ]
2 info using npm@6.12.0
3 info using node@v12.13.0
4 verbose run-script [ 'predeploy', 'deploy', 'postdeploy' ]
5 info lifecycle react-recipe-api@0.1.0~predeploy: react-recipe-api@0.1.0
6 verbose lifecycle react-recipe-api@0.1.0~predeploy: unsafe-perm in lifecycle true
7 verbose lifecycle react-recipe-api@0.1.0~predeploy: PATH: C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin;D:\Documents\Git-repo\finished\react-recipe-api\node_modules\.bin;C:\Python27\;C:\Python27\Scripts;C:\Program Files (x86)\Intel\iCLS Client\;C:\Program Files\Intel\iCLS Client\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\ProgramData\chocolatey\bin;C:\Program Files\nodejs\;;C:\Users\scorpio\AppData\Local\Programs\Microsoft VS Code\bin;C:\Users\scorpio\AppData\Roaming\npm
8 verbose lifecycle react-recipe-api@0.1.0~predeploy: CWD: D:\Documents\Git-repo\finished\react-recipe-api
9 silly lifecycle react-recipe-api@0.1.0~predeploy: Args: [ '/d /s /c', 'npm run build' ]
10 silly lifecycle react-recipe-api@0.1.0~predeploy: Returned: code: 0 signal: null
11 info lifecycle react-recipe-api@0.1.0~deploy: react-recipe-api@0.1.0
12 verbose lifecycle react-recipe-api@0.1.0~deploy: unsafe-perm in lifecycle true
13 verbose lifecycle react-recipe-api@0.1.0~deploy: PATH: C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin;D:\Documents\Git-repo\finished\react-recipe-api\node_modules\.bin;C:\Python27\;C:\Python27\Scripts;C:\Program Files (x86)\Intel\iCLS Client\;C:\Program Files\Intel\iCLS Client\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\ProgramData\chocolatey\bin;C:\Program Files\nodejs\;;C:\Users\scorpio\AppData\Local\Programs\Microsoft VS Code\bin;C:\Users\scorpio\AppData\Roaming\npm
14 verbose lifecycle react-recipe-api@0.1.0~deploy: CWD: D:\Documents\Git-repo\finished\react-recipe-api
15 silly lifecycle react-recipe-api@0.1.0~deploy: Args: [ '/d /s /c', 'gh-pages -d build' ]
16 silly lifecycle react-recipe-api@0.1.0~deploy: Returned: code: 1 signal: null
17 info lifecycle react-recipe-api@0.1.0~deploy: Failed to exec deploy script
18 verbose stack Error: react-recipe-api@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:210:5)
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:210:5)
18 verbose stack at maybeClose (internal/child_process.js:1021:16)
18 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:283:5)
19 verbose pkgid react-recipe-api@0.1.0
20 verbose cwd D:\Documents\Git-repo\finished\react-recipe-api
21 verbose Windows_NT 6.1.7601
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 v12.13.0
24 verbose npm v6.12.0
25 error code ELIFECYCLE
26 error errno 1
27 error react-recipe-api@0.1.0 deploy: `gh-pages -d build`
27 error Exit status 1
28 error Failed at the react-recipe-api@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 ]
这是我的package.json:
{
"name": "react-recipe-api",
"version": "0.1.0",
"private": true,
"homepage": "https://nicoding0.github.io/react-recipe-finder",
"dependencies": {
"react": "^16.12.0",
"react-dom": "^16.12.0",
"react-router-dom": "^5.1.2",
"react-scripts": "3.2.0",
"uuid": "^3.3.3"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject",
"predeploy": "npm run build",
"deploy": "gh-pages -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"
]
},
"devDependencies": {
"gh-pages": "^2.1.1"
}
}
我真的不知道出什么问题了,我有点迷茫,我确实遵循了所有步骤,但是我觉得我有点混乱了。
我知道Github Pages会在根目录中查找index.html来显示在页面上,但是npm run build创建一个带有已编译index.html的新文件夹。如果有人可以提供帮助,我将非常感谢,谢谢。
编辑:哦,这里是页面:https://nicoding0.github.io/react-recipe-finder/
和我的仓库:https://github.com/Nicoding0/react-recipe-finder
Edit2:我刚刚在使用create-react-app创建的全新React应用上进行了测试,并且发生了同样的事情,所以这告诉我这是我的问题,我的东西有什么问题?