我试图在GitHub,Firebase和Netlify上部署django-react应用。 在使用gh-pages部署在github-pages上时,出现此错误
sh: 1: gh-pages: not found
npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn
npm ERR! blog_frontend@0.1.0 deploy: `gh-pages -d build`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the blog_frontend@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! /home/pika/.npm/_logs/2018-08-09T15_30_32_229Z-debug.log
然后尝试使用Firebase。 首先,我安装firebase-tools
npm install -g firebase-tools
然后我无法在目录中初始化firebase。尝试
时firebase init
说
firebase: command not found
netlify也是如此。
这是gh页的错误日志文件
0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/bin/node', '/usr/local/bin/npm', 'run', 'deploy' ]
2 info using npm@6.2.0
3 info using node@v10.8.0
4 verbose run-script [ 'predeploy', 'deploy', 'postdeploy' ]
5 info lifecycle blog_frontend@0.1.0~predeploy: blog_frontend@0.1.0
6 verbose lifecycle blog_frontend@0.1.0~predeploy: unsafe-perm in lifecycle true
7 verbose lifecycle blog_frontend@0.1.0~predeploy: PATH: /usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/home/pika/Desktop/django/Django-React-Blog/frontend/blog_frontend/node_modules/.bin:/home/pika/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
8 verbose lifecycle blog_frontend@0.1.0~predeploy: CWD: /home/pika/Desktop/django/Django-React-Blog/frontend/blog_frontend
9 silly lifecycle blog_frontend@0.1.0~predeploy: Args: [ '-c', 'npm run build' ]
10 silly lifecycle blog_frontend@0.1.0~predeploy: Returned: code: 0 signal: null
11 info lifecycle blog_frontend@0.1.0~deploy: blog_frontend@0.1.0
12 verbose lifecycle blog_frontend@0.1.0~deploy: unsafe-perm in lifecycle true
13 verbose lifecycle blog_frontend@0.1.0~deploy: PATH: /usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/home/pika/Desktop/django/Django-React-Blog/frontend/blog_frontend/node_modules/.bin:/home/pika/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
14 verbose lifecycle blog_frontend@0.1.0~deploy: CWD: /home/pika/Desktop/django/Django-React-Blog/frontend/blog_frontend
15 silly lifecycle blog_frontend@0.1.0~deploy: Args: [ '-c', 'gh-pages -d build' ]
16 info lifecycle blog_frontend@0.1.0~deploy: Failed to exec deploy script
17 verbose stack Error: blog_frontend@0.1.0 deploy: `gh-pages -d build`
17 verbose stack spawn ENOENT
17 verbose stack at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:48:18)
17 verbose stack at ChildProcess.emit (events.js:182:13)
17 verbose stack at maybeClose (internal/child_process.js:962:16)
17 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:249:5)
18 verbose pkgid blog_frontend@0.1.0
19 verbose cwd /home/pika/Desktop/django/Django-React-Blog/frontend/blog_frontend
20 verbose Linux 4.15.0-29-generic
21 verbose argv "/usr/local/bin/node" "/usr/local/bin/npm" "run" "deploy"
22 verbose node v10.8.0
23 verbose npm v6.2.0
24 error file sh
25 error code ELIFECYCLE
26 error errno ENOENT
27 error syscall spawn
28 error blog_frontend@0.1.0 deploy: `gh-pages -d build`
28 error spawn ENOENT
29 error Failed at the blog_frontend@0.1.0 deploy script.
29 error This is probably not a problem with npm. There is likely additional logging output above.
30 verbose exit [ 1, true ]
答案 0 :(得分:0)
在package.json文件中缺少gh-pages
依赖性。
我知道这来得太晚了,但是也许可以帮助处于相同修复状态的某人。最近我发布了与Github Pages类似的错误,但我仍然不知道它是如何发生的,但是以某种方式不再安装我的gh-pages
依赖项。我想我可能在废弃的分支之类的地方使用了它。
仅在终端上运行npm install --save gh-pages
即可恢复我的应用...以及我的理智,哈哈。这确实是一个令人讨厌的小错误。
我希望这仍然与具有类似解决方案的人有关。
答案 1 :(得分:0)
我只是有同样的错误。我使用的是Firebase托管,但添加了Firebase Cloud Functions。这修改了我的firebase.json
文件:
{
"hosting": {
"public": "build",
"ignore": [
"firebase.json",
"**/.*",
"**/node_modules/**"
],
"rewrites": [
{
"source": "**",
"destination": "/index.html"
}
]
},
"functions": {
}
}
我最初使用eslint设置Cloud Functions,但后来决定将其删除。似乎有空的"functions": {}
部分正在破坏部署,即使执行firebase deploy --only hosting
也是如此。
运行--debug
或只是反复尝试(Firebase工具似乎可以记录反复的故障并转储日志文件),揭示了实际原因(至少对我而言):
[2020-05-16T20:26:53.762Z] TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined
at validateString (internal/validators.js:121:11)
at Object.join (path.js:1039:7)
at Object.checkFunctionsSDKVersion [as fn] (/usr/lib/node_modules/firebase-tools/lib/checkFirebaseSDKVersion.js:33:28)
at Command.<anonymous> (/usr/lib/node_modules/firebase-tools/lib/command.js:159:30)
at Generator.next (<anonymous>)
at fulfilled (/usr/lib/node_modules/firebase-tools/lib/command.js:5:58)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
Error: An unexpected error has occurred.
好像我的json不适合firebase或firebase本身有问题。
通过删除, "functions": {}
文件中空的firebase.json
部分,我能够使托管部署再次正常工作。