Hexo升级与问题排除(TypeError: line.matchAll is not a function)

Hexo的等级提升了!

野生的问题出现了!

问题被打败了!


Hexo升级

由于我的升级方法一定不是最佳的(通过npm audit+manual操作升级),故摘网上的升级方法于此。

作者:LANVNAL
链接:https://www.jianshu.com/p/802182c01b59
来源:简书
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。

  1. 全局升级hexo-cli,先hexo version查看当前版本,然后npm i hexo-cli -g,再次hexo version查看是否升级成功。

  2. 使用npm install -g npm-checknpm-check,检查系统中的插件是否有升级的,可以看到自己前面都安装了那些插件

  3. 使用npm install -g npm-upgradenpm-upgrade,升级系统中的插件

  4. 使用npm update -gnpm update --save

问题排查

升级后在hexo g时出现错误,具体报错如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
INFO  Validating config
INFO Start processing
FATAL { err:
TypeError: line.matchAll is not a function
at res.value.res.value.split.map.line (/**/hexosite/node_modules/hexo-util/lib/highlight.js:128:26)
at Array.map (<anonymous>)
at closeTags (/**/hexosite/node_modules/hexo-util/lib/highlight.js:126:37)
at highlight (/**/hexosite/node_modules/hexo-util/lib/highlight.js:119:10)
at highlightUtil (/**/hexosite/node_modules/hexo-util/lib/highlight.js:23:16)
at data.content.dataContent.replace (/**/hexosite/node_modules/hexo/lib/plugins/filter/before_post_render/backtick_code_block.js:92:17)
at String.replace (<anonymous>)
at Hexo.backtickCodeBlock (/**/hexosite/node_modules/hexo/lib/plugins/filter/before_post_render/backtick_code_block.js:19:30)
at Hexo.tryCatcher (/**/hexosite/node_modules/bluebird/js/release/util.js:16:23)
at Hexo.<anonymous> (/**/hexosite/node_modules/bluebird/js/release/method.js:15:34)
at Promise.each.filter (/**/hexosite/node_modules/hexo/lib/extend/filter.js:67:52)
at tryCatcher (/**/hexosite/node_modules/bluebird/js/release/util.js:16:23)
at Object.gotValue (/**/hexosite/node_modules/bluebird/js/release/reduce.js:166:18)
at Object.gotAccum (/**/hexosite/node_modules/bluebird/js/release/reduce.js:155:25)
at Object.tryCatcher (/**/hexosite/node_modules/bluebird/js/release/util.js:16:23)
at Promise._settlePromiseFromHandler (/**/hexosite/node_modules/bluebird/js/release/promise.js:547:31)
at Promise._settlePromise (/**/hexosite/node_modules/bluebird/js/release/promise.js:604:18)
at Promise._settlePromiseCtx (/**/hexosite/node_modules/bluebird/js/release/promise.js:641:10)
at _drainQueueStep (/**/hexosite/node_modules/bluebird/js/release/async.js:97:12)
at _drainQueue (/**/hexosite/node_modules/bluebird/js/release/async.js:86:9)
at Async._drainQueues (/**/hexosite/node_modules/bluebird/js/release/async.js:102:5)
at Immediate.Async.drainQueues [as _onImmediate] (/**/hexosite/node_modules/bluebird/js/release/async.js:15:14) }
'Something\'s wrong. Maybe you can find the solution here: %s' '\u001b[4mhttps://hexo.io/docs/troubleshooting.html\u001b[24m'

经排查,发现问题出现在Node.js的版本上。由于Node.js 10在2021年8月30日已停止服务,新版本的Hexo需要Node.js版本在12.0+。

但ubuntu默认软件源仓库中Node.js的版本仍为10,故需要额外的步骤来更新:

  1. 首先更新系统以保证不会发生依赖错误:

    1
    2
    sudo apt update
    sudo apt -y upgrade
  2. 添加仓库

    1
    2
    3
    sudo apt update
    sudo apt -y install curl dirmngr apt-transport-https lsb-release ca-certificates
    curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash -
  3. 更新Node

    1
    sudo apt -y install nodejs

自此,故障得以解决。