因为Win10的自动更新把系统彻底搞崩了,重装之后需要恢复hexo环境,正好借机将原来的2.X版本升级到最新版3.2.2,记录下过程以及中间遇到的问题:
nodejs&&git
没什么好说的从官网下载最新版安装即可
安装hexo
npm install -g hexo-cli
新版的hexo把很多部分拆出来模块化了,还需要单独安装,主要需要后安装server和git部署模块npm install hexo-server --save
npm install hexo-deployer-git --save
文件迁移
我选择新init了一个目录来做迁移,init之后比照着修改_config.yml
,之后将原来的source_posts下的md文件全部复制过来,以及themes\metro-light经过我细微修改的metro-light主题目录
生成
然后hexo g生成测试下,报错了。。
INFO Start processing
FATAL Something's wrong. Maybe you can find the solution here: http://hexo.io/docs/troubleshooting.html
Template render error: (unknown path) [Line 7, Column 23]
Error: Unable to call `the return value of (posts["first"])["updated"]["toISOString"]`, which is undefined or falsey
at Object.exports.prettifyError (D:\OneDrive\blog\node_modules\hexo-generator-feed\node_modules\nunjucks\src\lib.js:34:15)
at D:\OneDrive\blog\node_modules\hexo-generator-feed\node_modules\nunjucks\src\environment.js:486:31
at root [as rootRenderFunc] (eval at <anonymous> (D:\OneDrive\blog\node_modules\hexo-generator-feed\node_modules\nunjucks\src\environment.js:565:24), <anonymous>:161:3)
at Obj.extend.render (D:\OneDrive\blog\node_modules\hexo-generator-feed\node_modules\nunjucks\src\environment.js:479:15)
at Hexo.module.exports (D:\OneDrive\blog\node_modules\hexo-generator-feed\lib\generator.js:28:22)
at Hexo.tryCatcher (D:\OneDrive\blog\node_modules\hexo\node_modules\bluebird\js\release\util.js:16:23)
at Hexo.<anonymous> (D:\OneDrive\blog\node_modules\hexo\node_modules\bluebird\js\release\method.js:15:34)
at D:\OneDrive\blog\node_modules\hexo\lib\hexo\index.js:337:24
at tryCatcher (D:\OneDrive\blog\node_modules\hexo\node_modules\bluebird\js\release\util.js:16:23)
at MappingPromiseArray._promiseFulfilled (D:\OneDrive\blog\node_modules\hexo\node_modules\bluebird\js\release\map.js:61:38)
at MappingPromiseArray.PromiseArray._iterate (D:\OneDrive\blog\node_modules\hexo\node_modules\bluebird\js\release\promise_array.js:113:31)
at MappingPromiseArray.init (D:\OneDrive\blog\node_modules\hexo\node_modules\bluebird\js\release\promise_array.js:77:10)
at MappingPromiseArray._asyncInit (D:\OneDrive\blog\node_modules\hexo\node_modules\bluebird\js\release\map.js:30:10)
at Async._drainQueue (D:\OneDrive\blog\node_modules\hexo\node_modules\bluebird\js\release\async.js:143:12)
at Async._drainQueues (D:\OneDrive\blog\node_modules\hexo\node_modules\bluebird\js\release\async.js:148:10)
at Immediate.Async.drainQueues [as _onImmediate] (D:\OneDrive\blog\node_modules\hexo\node_modules\bluebird\js\release\async.js:17:14)
at processImmediate [as _immediateCallback] (timers.js:383:17)
FATAL (unknown path) [Line 7, Column 23]
Error: Unable to call `the return value of (posts["first"])["updated"]["toISOString"]`, which is undefined or falsey
Template render error: (unknown path) [Line 7, Column 23]
Error: Unable to call `the return value of (posts["first"])["updated"]["toISOString"]`, which is undefined or falsey
at Object.exports.prettifyError (D:\OneDrive\blog\node_modules\hexo-generator-feed\node_modules\nunjucks\src\lib.js:34:15)
at D:\OneDrive\blog\node_modules\hexo-generator-feed\node_modules\nunjucks\src\environment.js:486:31
at root [as rootRenderFunc] (eval at <anonymous> (D:\OneDrive\blog\node_modules\hexo-generator-feed\node_modules\nunjucks\src\environment.js:565:24), <anonymous>:161:3)
at Obj.extend.render (D:\OneDrive\blog\node_modules\hexo-generator-feed\node_modules\nunjucks\src\environment.js:479:15)
at Hexo.module.exports (D:\OneDrive\blog\node_modules\hexo-generator-feed\lib\generator.js:28:22)
at Hexo.tryCatcher (D:\OneDrive\blog\node_modules\hexo\node_modules\bluebird\js\release\util.js:16:23)
at Hexo.<anonymous> (D:\OneDrive\blog\node_modules\hexo\node_modules\bluebird\js\release\method.js:15:34)
at D:\OneDrive\blog\node_modules\hexo\lib\hexo\index.js:337:24
at tryCatcher (D:\OneDrive\blog\node_modules\hexo\node_modules\bluebird\js\release\util.js:16:23)
at MappingPromiseArray._promiseFulfilled (D:\OneDrive\blog\node_modules\hexo\node_modules\bluebird\js\release\map.js:61:38)
at MappingPromiseArray.PromiseArray._iterate (D:\OneDrive\blog\node_modules\hexo\node_modules\bluebird\js\release\promise_array.js:113:31)
at MappingPromiseArray.init (D:\OneDrive\blog\node_modules\hexo\node_modules\bluebird\js\release\promise_array.js:77:10)
at MappingPromiseArray._asyncInit (D:\OneDrive\blog\node_modules\hexo\node_modules\bluebird\js\release\map.js:30:10)
at Async._drainQueue (D:\OneDrive\blog\node_modules\hexo\node_modules\bluebird\js\release\async.js:143:12)
at Async._drainQueues (D:\OneDrive\blog\node_modules\hexo\node_modules\bluebird\js\release\async.js:148:10)
at Immediate.Async.drainQueues [as _onImmediate] (D:\OneDrive\blog\node_modules\hexo\node_modules\bluebird\js\release\async.js:17:14)
at processImmediate [as _immediateCallback] (timers.js:383:17)
看了眼似乎是hexo-generator-feed插件的问题
_config.yml:
plugins:
##- hexo-generator-feed
注释掉这个插件后能够顺利生成了
看这个插件的Github上的issue目测是还没支持3.2.2(后面发现不是这个问题)
https://github.com/hexojs/hexo-generator-feed/issues/43
P.S.新版本的生成过程中输出信息少了很多,一度以为有问题,new了个新文章发现也是这样。
本地测试
之后准备运行server来本地先看看效果。结果hexo server说没有这个命令。。顿时迷茫了。。尝试重装了hexo和hexo-server依然不行,各种研究之后看到一个说是因为配置文件里的plugins项,看了眼hexo 3.0的改动日志。
Plugin Loading Mechanism
In Hexo 3, only plugins listed in package.json will be loaded, and plugins/scripts will be executed in sandbox so hexo namespace will be no longer exposed to global.
这样看来_config.yml中的plugins项就失去了意义直接删除之后就可以顺利运行,连上面注释掉的feed插件也正常了。比照了下网站上的内容,发现没什么问题,进入下一步部署相关内容。
部署
先在Git Bash里生成ssh密钥ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
将公钥配置到Github和Coding.net中(我是同时部署到这两个网站,在dnspod里配置DNS信息,联通和电信访问Coding.net其他就访问Github)
再ssh -T git@github.com
ssh -T git@git.coding.net
测试下连通性,第一次的话一般会提示:
The authenticity of host 'github.com (192.30.253.113)' can't be established.
RSA key fingerprint is SHA256:nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'github.com,192.30.253.113' (RSA) to the list of known hosts.
Hi XXXXXXX! You've successfully authenticated, but GitHub does not provide shell access.
将网站的公钥加入到known_hosts中。