0%

Hexo-Next升级记录

好久没更新博客了,回想起这还是20年搭的博客,强迫症选手想升级下相关组件,需要升级的有Node.js, Hexo和Next。

升级Hexo

升级Hexo只需要在package.json配置hexo的版本号,然后再install更新即可yarn install

比如当前hexo的最新版本是6.3,配置"hexo": "^6.3.0"

升级Node.js

尝试把nodejs升级到18,遇到了几个问题,网上如果中文搜索到大多都是让退回12,这种治标不治本的解决方案当然不可以接受,不过还好nodejs14出现很久了,其实相关问题都有解决方案

Node.js 14以上循环依赖错误

报错如下

1
2
3
4
5
6
(node:16596) Warning: Accessing non-existent property 'lineno' of module exports inside circular dependency
(node:16596) Warning: Accessing non-existent property 'column' of module exports inside circular dependency
(node:16596) Warning: Accessing non-existent property 'filename' of module exports inside circular dependency
(node:16596) Warning: Accessing non-existent property 'lineno' of module exports inside circular dependency
(node:16596) Warning: Accessing non-existent property 'column' of module exports inside circular dependency
(node:16596) Warning: Accessing non-existent property 'filename' of module exports inside circular dependency

参考了解决 Hexo 在使用 Node.js 14,应该是stylus导致的问题,可以利用npx分析能力:

1
npx cross-env NODE_OPTIONS="--trace-warnings" hexo s

Node.js 18出现Database load failed

错误信息:Database load failed. Deleting database.

在Github上搜到的一个issue:Database load failed on Node 18.6.0,是由于warehouse低版本导致的一个错误,需要把升级到4.0.2以上,因此在package.json中配置最低版本号(注意resolutions只针对yarn生效):

1
2
3
"resolutions": {
"warehouse": "^4.0.2"
}

Deploy是出现类型错误

运行命令hexo d -g时,出现如下错误信息:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
TypeError [ERR_INVALID_ARG_TYPE]: The "mode" argument must be integer. Received an instance of Object
at copyFile (node:fs:2840:10)
at tryCatcher (<path>\node_modules\bluebird\js\release\util.js:16:23)
at ret (eval at makeNodePromisifiedEval (<path>\npm\node_modules\hexo-cli\node_modules\bluebird\js\release\promisify.js:184:12), <anonymous>:13:39)
at <path>\node_modules\hexo-deployer-git\node_modules\hexo-fs\lib\fs.js:144:39
at tryCatcher (<path>\node_modules\bluebird\js\release\util.js:16:23)
at Promise._settlePromiseFromHandler (<path>\node_modules\bluebird\js\release\promise.js:547:31)
at Promise._settlePromise (<path>\node_modules\bluebird\js\release\promise.js:604:18)
at Promise._settlePromise0 (<path>\node_modules\bluebird\js\release\promise.js:649:10)
at Promise._settlePromises (<path>\node_modules\bluebird\js\release\promise.js:729:18)
at Promise._fulfill (<path>\node_modules\bluebird\js\release\promise.js:673:18)
at Promise._resolveCallback (<path>\node_modules\bluebird\js\release\promise.js:466:57)
at Promise._settlePromiseFromHandler (<path>\node_modules\bluebird\js\release\promise.js:559:17)
at Promise._settlePromise (<path>\node_modules\bluebird\js\release\promise.js:604:18)
at Promise._settlePromise0 (<path>\node_modules\bluebird\js\release\promise.js:649:10)
at Promise._settlePromises (<path>\node_modules\bluebird\js\release\promise.js:729:18)
at Promise._fulfill (<path>\node_modules\bluebird\js\release\promise.js:673:18)
at Promise._resolveCallback (<path>\node_modules\bluebird\js\release\promise.js:466:57)
at Promise._settlePromiseFromHandler (<path>\node_modules\bluebird\js\release\promise.js:559:17)
at Promise._settlePromise (<path>\node_modules\bluebird\js\release\promise.js:604:18)
at Promise._settlePromise0 (<path>\node_modules\bluebird\js\release\promise.js:649:10)
at Promise._settlePromises (<path>\node_modules\bluebird\js\release\promise.js:729:18)
at Promise._fulfill (<path>\node_modules\bluebird\js\release\promise.js:673:18)

找到一个issue,在最后yoshinorin的解答是有效的,原因是hexo-fs的版本不兼容,需要至少升级至2.0.1才可以,同上一个问题,设置版本"hexo-fs": "^2.0.1"