Cannot set property 'lastIndex' of undefined

问题描述

使用hexo g部署博客的时候,出现以下错误:

关键字:'lastIndex' of undefined

1
2
3
4
5
6
7
8
9
10
11
12
$ hexo g
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 (E:\My_blog\node_modules\highlight.js\lib\highlight.js:523:35)
at E:\My_blog\node_modules\highlight.js\lib\highlight.js:573:21
at Array.forEach (<anonymous>)
at Object.highlightAuto (E:\My_blog\node_modules\highlight.js\lib\highlight.js:572:62)
at E:\My_blog\node_modules\hexo-util\lib\highlight.js:117:25
at highlight (E:\My_blog\node_modules\hexo-util\lib\highlight.js:120:7)
at highlightUtil (E:\My_blog\node_modules\hexo-util\lib\highlight.js:22:14)
at data.content.data.content.replace (E:\My_blog\node_modules\hexo\lib\plugins\filter\before_post_render\backtick_code_block.js:59:15)

解决办法

修改hexo配置文件的 _config.yml,注意不是主题里面的配置文件!
把 auto_detect 设置为false 即可。