hexo server时报template render error (unknown path)

hexo 在win下可以正常使用,在ubuntu 18.04和macOS中会报如下错误:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
Template render error: (unknown path) [Line 8, Column 25]
Error: Unable to call `the return value of (posts["first"])["updated"]["toISOString"]`, which is undefined or falsey
at Object._prettifyError (/Users/kevinkong/Documents/codes/hexo/hexo/node_modules/nunjucks/src/lib.js:36:11)
at /Users/kevinkong/Documents/codes/hexo/hexo/node_modules/nunjucks/src/environment.js:567:19
at Template.root [as rootRenderFunc] (eval at _compile (/Users/kevinkong/Documents/codes/hexo/hexo/node_modules/nunjucks/src/environment.js:637:18), <anonymous>:214:3)
at Template.render (/Users/kevinkong/Documents/codes/hexo/hexo/node_modules/nunjucks/src/environment.js:556:10)
at Hexo.module.exports (/Users/kevinkong/Documents/codes/hexo/hexo/node_modules/hexo-generator-feed/lib/generator.js:40:22)
at Hexo.tryCatcher (/Users/kevinkong/Documents/codes/hexo/hexo/node_modules/bluebird/js/release/util.js:16:23)
at Hexo.<anonymous> (/Users/kevinkong/Documents/codes/hexo/hexo/node_modules/bluebird/js/release/method.js:15:34)
at Promise.map.key (/Users/kevinkong/Documents/codes/hexo/hexo/node_modules/hexo/lib/hexo/index.js:318:20)
at tryCatcher (/Users/kevinkong/Documents/codes/hexo/hexo/node_modules/bluebird/js/release/util.js:16:23)
at MappingPromiseArray._promiseFulfilled (/Users/kevinkong/Documents/codes/hexo/hexo/node_modules/bluebird/js/release/map.js:61:38)
at MappingPromiseArray.PromiseArray._iterate (/Users/kevinkong/Documents/codes/hexo/hexo/node_modules/bluebird/js/release/promise_array.js:114:31)
at MappingPromiseArray.init (/Users/kevinkong/Documents/codes/hexo/hexo/node_modules/bluebird/js/release/promise_array.js:78:10)
at MappingPromiseArray._asyncInit (/Users/kevinkong/Documents/codes/hexo/hexo/node_modules/bluebird/js/release/map.js:30:10)
at _drainQueueStep (/Users/kevinkong/Documents/codes/hexo/hexo/node_modules/bluebird/js/release/async.js:142:12)
at _drainQueue (/Users/kevinkong/Documents/codes/hexo/hexo/node_modules/bluebird/js/release/async.js:131:9)
at Async._drainQueues (/Users/kevinkong/Documents/codes/hexo/hexo/node_modules/bluebird/js/release/async.js:147:5)
at Immediate.Async.drainQueues [as _onImmediate] (/Users/kevinkong/Documents/codes/hexo/hexo/node_modules/bluebird/js/release/async.js:17:14)
at runCallback (timers.js:705:18)
at tryOnImmediate (timers.js:676:5)
at processImmediate (timers.js:658:5)

最初以为是操作系统的问题,升级npm、nodejs等方法均不起作用。

后来在github上的一个issue中找到了答案,原来是hexo-generator-sitemap, hexo-generator-feed两个插件不兼容hexo3 导致的。

解决方案,卸载hexo-generator-sitemap, hexo-generator-feed连个插件。

1
2
sudo npm uninstall hexo-generator-sitemap
sudo npm uninstall hexo-generator-feed
你的支持我的动力