TypeError: Cannot set property 'lastIndex' of undefined

环境

节点版本 (node -v)

v10.13.0

插件版本 (npm ls --depth 0)

[email protected] D:\WorkspaceIdea\blog
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
`-- [email protected]

错误信息

Bug信息 (hexo s)

INFO  Start processing
FATAL Something's wrong. Maybe you can find the solution here: http://hexo.io/docs/troubleshooting.html
TypeError: Cannot set property 'lastIndex' of undefined
    at highlight (D:\blog\node_modules\highlight.js\lib\highlight.js:523:35)
    at D:\blog\node_modules\highlight.js\lib\highlight.js:573:21
    at Array.forEach ()
    at Object.highlightAuto (D:\blog\node_modules\highlight.js\lib\highlight.js:572:62)
    at D:\blog\node_modules\hexo-util\lib\highlight.js:117:25
    at highlight (D:\blog\node_modules\hexo-util\lib\highlight.js:120:7)
    at highlightUtil (D:\blog\node_modules\hexo-util\lib\highlight.js:22:14)
    at data.content.data.content.replace (D:\blog\node_modules\hexo\lib\plugins\filter\before_post_render\backtick_code_block.js:59:15)
    at String.replace ()
    at Hexo.backtickCodeBlock (D:\blog\node_modules\hexo\lib\plugins\filter\before_post_render\backtick_code_block.js:14:31)
    at Hexo.tryCatcher (D:\blog\node_modules\bluebird\js\release\util.js:16:23)
    at Hexo. (D:\blog\node_modules\bluebird\js\release\method.js:15:34)
    at Promise.each.filter (D:\blog\node_modules\hexo\lib\extend\filter.js:63:65)
    at tryCatcher (D:\blog\node_modules\bluebird\js\release\util.js:16:23)
    at Object.gotValue (D:\blog\node_modules\bluebird\js\release\reduce.js:155:18)
    at Object.gotAccum (D:\blog\node_modules\bluebird\js\release\reduce.js:144:25)
    at Object.tryCatcher (D:\blog\node_modules\bluebird\js\release\util.js:16:23)
    at Promise._settlePromiseFromHandler (D:\blog\node_modules\bluebird\js\release\promise.js:512:31)
    at Promise._settlePromise (D:\blog\node_modules\bluebird\js\release\promise.js:569:18)
    at Promise._settlePromiseCtx (D:\blog\node_modules\bluebird\js\release\promise.js:606:10)
    at _drainQueueStep (D:\blog\node_modules\bluebird\js\release\async.js:142:12)
    at _drainQueue (D:\blog\node_modules\bluebird\js\release\async.js:131:9)

错误原因:

auto_detect设置为自动检测语言,github源码地址使用说明:https://github.com/hexojs/hexo-util#highlightstr-options

我认为问题是由highlight.js尝试检测代码语言引起的。
TypeError: Cannot set property 'lastIndex' of undefined_第1张图片

解决办法:

_config.yml中设置auto_detect:false为我解决了这个问题:

打开_config.yml文件,修改如下配置:

highlight: 
  enable:true 
  line_number:false 
  auto_detect:false 
  tab_replace:



你可能感兴趣的:(Bug)