Hexo: 升级到hexo 3.0后deploy type: github选项无效

Created on 26 Jan 2015  ·  42Comments  ·  Source: hexojs/hexo

必须要将config.yml中的github修改为git才能正常deploy。
这个不算BUG,无伤大雅,在wiki里面提一句就好,除了修改type之外别的不需要修改。

Most helpful comment

npm install hexo-deployer-git --save
目测你是把那个--save漏掉了。

All 42 comments

请问怎么升级到 3.0

同问,怎么升级, npm 上还是 2.8.3 的

原来 wiki 上有,多谢,以后有事先去 wiki 上瞄一下

  • _config.yml 文件:
deploy:
  type: git
  repo: [email protected]:wanggnim/Gnim.git
  branch: gh-pages
  • node_modules文件夹:
2015/06/11  10:15    <DIR>          .
2015/06/11  10:15    <DIR>          ..
2015/06/10  21:47    <DIR>          .bin
2015/06/10  21:47    <DIR>          hexo
2015/06/11  10:15    <DIR>          hexo-deployer-git
2015/06/10  21:47    <DIR>          hexo-generator-archive
2015/06/10  21:47    <DIR>          hexo-generator-category
2015/06/10  21:47    <DIR>          hexo-generator-index
2015/06/10  21:47    <DIR>          hexo-generator-tag
2015/06/10  21:47    <DIR>          hexo-renderer-ejs
2015/06/10  21:47    <DIR>          hexo-renderer-marked
2015/06/10  21:47    <DIR>          hexo-renderer-stylus
2015/06/10  21:47    <DIR>          hexo-server
               0 File(s)              0 bytes
              13 Dir(s)  119,912,251,392 bytes free
  • 然后执行:hexo deploy
  • 提示:ERROR Deployer not found: git

这是为什么

npm install hexo-deployer-git --save
目测你是把那个--save漏掉了。

我的hexo-deployer-git已经安装了,不过我又执行了一遍npm install hexo-deployer-git --save.

但是node_modules目录没有发生变化

2015/06/11  10:15    <DIR>          .
2015/06/11  10:15    <DIR>          ..
2015/06/10  21:47    <DIR>          .bin
2015/06/10  21:47    <DIR>          hexo
2015/06/11  10:15    <DIR>          hexo-deployer-git
2015/06/10  21:47    <DIR>          hexo-generator-archive
2015/06/10  21:47    <DIR>          hexo-generator-category
2015/06/10  21:47    <DIR>          hexo-generator-index
2015/06/10  21:47    <DIR>          hexo-generator-tag
2015/06/10  21:47    <DIR>          hexo-renderer-ejs
2015/06/10  21:47    <DIR>          hexo-renderer-marked
2015/06/10  21:47    <DIR>          hexo-renderer-stylus
2015/06/10  21:47    <DIR>          hexo-server
               0 File(s)              0 bytes
              13 Dir(s)  119,912,251,392 bytes free

而且我在安装npm install hexo-deployer-git --save的时候遇到了

hexonpm ERR! Windows_NT 6.1.7601
npm ERR! argv "D:\\Program Files\\nodejs\\\\node.exe" "D:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "hexo-deployer-git" "--save"
npm ERR! node v0.12.2
npm ERR! npm  v2.7.4
npm ERR! code EIO
npm ERR! errno EIO
npm ERR! syscall write

npm ERR! write EIO
npm ERR! 
npm ERR! If you need help, you may report this error at:
npm ERR!     <https://github.com/npm/npm/issues>

npm ERR! Please include the following file with any support request:
npm ERR!     D:\gitrep\gnim\branches\hexo\npm-debug.log

的问题,我安装所有的node模块都会遇到这个问题,但是hexo generatehexo server可以正常使用,

执行

D:\gitrep\branches\hexo>hexo deploy
ERROR Deployer not found: git

还是不成功

换个文件夹重新hexo init,试试呢?

仍然不行

我之前之所以提出要进行npm install hexo-deployer-git --save,是因为我看过了你的package.json,发现里面并没有注册hexo-deployer-git的相关信息。所以判断你之前安装hexo-deployer-git的时候并不是使用--save参数安装的。

所以,我觉得可以尝试一下npm uninsatll hexo-depolyer-git,再执行npm install hexo-deployer-git --save。如果还是不行,只能重装nodejs环境试试了。

我的操作步骤

hexo init
npm install hexo --save
hexo g
npm install
npm install hexo-deployer-git --save
hexo g
hexo d

_config.yml

deploy:
  type: git
  message: "g"
  repo: 
    github: [email protected]:wanggnim/Gnim.git,gh-pages

在使用npm安装的时候,总是报错

D:\tmp\hexo1>npm install hexo-deployer-git --save
-/-|-|||-\/--\\|/\|/--\\|/|/--\|/-|--\\|\\\|/-|\\|//-|/--\/|\|--\-\|-\|\\|-|-\|/-\/|npm WARN optional dep failed, continuing [email protected]
/-\|/-\\|/|/-\|/|\|/hexonpm ERR! Windows_NT 6.1.7601
npm ERR! argv "D:\\Program Files\\nodejs\\\\node.exe" "D:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "hexo-deployer-git" "--save"
npm ERR! node v0.12.2
npm ERR! npm  v2.7.4
npm ERR! code EIO
npm ERR! errno EIO
npm ERR! syscall write

npm ERR! write EIO
npm ERR! 
npm ERR! If you need help, you may report this error at:
npm ERR!     <https://github.com/npm/npm/issues>

npm ERR! Please include the following file with any support request:
npm ERR!     D:\tmp\hexo1\npm-debug.log

我也有见其他朋友提到过这个问题,是node.js的问题吗

是不是还需要io.js啊

http://stackoverflow.com/questions/17035399/why-this-error-happend-nodejs-error-write-eio

Thus your problem could very well be related to the encoding your environment is in.

看起来是编码问题,你检查看看。

ok,我去看看,谢谢你

除此以外,还有可能是权限问题,你用管理员模式试试看?

参考:https://cnodejs.org/topic/521c7a50bee8d3cb12b4bfec

用管理员不行,我回家换个系统,不用windows试试看

我觉得这个去npm那边交issue可能更有帮助些

hexo deploy的时候可以选择不删除远程仓库的原来文件吗?

不可以,因为每次都是git push --force

_config.yml

# URL
## If your site is put in a subdirectory, set url as 'http://yoursite.com/child' and root as '/child/'
url: www.gnim.wang
root: /hexo
permalink: :year/:month/:day/:title/
permalink_defaults:

我想将生成的东西部署到gh-pages/hexo这个目录内?但是我这么配置URL,却发现仍然是在gh-pages这个目录下?

并不能生成到那个目录去。
想实现这样的功能,需要你的yourname.github.io中CNAME指向www.gnim.wang,然后你再新建一个hexo的库,你就可以通过www.gnim.wang/hexo访问了

那这个配置是用来干什么的

# URL
## If your site is put in a subdirectory, set url as 'http://yoursite.com/child' and root as '/child/'
url: www.gnim.wang
root: /hexo
permalink: :year/:month/:day/:title/
permalink_defaults:

子目录,相对于你的URL而言的,而不是说会放在你库中的某个子目录

有个问题你是怎么解决的?就是gh-pages里需要一个CNAME文件,但是每次重新部署的时候,都会将这个CNAME文件删掉

hexo-deployer-git项目里,我看源码deplover.js里有一段

  function push(repo){
    return git('add', '-A').then(function(){
      return git('commit', '-m', message).catch(function(){
        // Do nothing. It's OK if nothing to commit.
      });
    }).then(function(){
      return git('push', '-u', repo.url, 'HEAD:' + repo.branch, '--force');
    });
  }

我搜索了一下git push 的--force解释: 如果远程主机的版本比本地版本更新,推送时Git会报错,要求先在本地做git pull合并差异,然后再推送到远程主机。这时,如果你一定要推送,可以使用–force选项。
使用–force选项,结果导致在远程主机产生一个”非直进式”的合并(non-fast-forward merge)。

是这个原因将原来的内容都清掉了吗

放在source文件夹里面

什么放在source文件夹下

哦,知道了,CNAME放到source

现在我有一个gitbook生成的网站,放在source下也是可以的是吗

用skip_render

我是新手 我的uesrname这个repo上已经有了hexo的代码 但不知道为什么 我的username.github.io还是
404了 是我账号的问题吗

答楼上,应该是传的文件错了

@gamblenull1996 repo里面应该是html之类的静态页面的代码,而不是md文件
@Baymaxxx 可以是用AT来指定回复,不用AT的话,那个人不一定会看到~

`
G:\opensource\hexo>hexo deploy
INFO Deploying: git
INFO Setting up Git deployment...
events.js:85
throw er; // Unhandled 'error' event
^
Error: spawn git ENOENT
at exports._errnoException (util.js:746:11)
at Process.ChildProcess._handle.onexit (child_
at child_process.js:1144:20
at process._tickCallback (node.js:355:11)

`
修改成git后再发布是这个错误

我的问题是 Permission denied (publickey) SSH key重复弄了很多次。每次都是连接不上...

@zeng233 Win的话,你需要检查git是否已经添加到path中
@xiongyu1988 你可以把.deploy_git文件夹删除之后再试,当然首先要保证ssh -T github.com没有问题。

@Xuanwo 我那个问题解决好了,要在git的命令行下执行hexo deploy,这样就可以发布到github了

hexo d命令后报这个错:
INFO Deploying: git
FATAL Something's wrong. Maybe you can find the solution here: http://hexo.io/docs/troubleshooting.html

然后一堆标灰文字,正中间来了个:FATAL source.replace is not a function

我的gitgnore中是这样的:
.DS_Store
Thumbs.db
db.json
_.log
node_modules/
public/
.deploy_/

我的config.yml是这样的:
deploy:
type: git
repo: https://github.com/sunlanda/sunlanda-blog
branch: [gh-pages]
message: [message]

求助什么问题和解决方法 (总是deploy不上呢 )

@sunlanda

branch: [gh-pages]
message: [message]

删除所有的方括号。

PS:当前issue已经关闭,为了避免打扰他人,有问题时请开启新的issue。

今天遇到了这个问题 发现root cause是 "-" 打成了中文的。。。切换回英文输入法以后就好了

Was this page helpful?
0 / 5 - 0 ratings