1. 程式人生 > >hexo釋出文章報錯記錄:Unhandled rejection TypeError: Cannot set property 'lastIndex' of undefined

hexo釋出文章報錯記錄:Unhandled rejection TypeError: Cannot set property 'lastIndex' of undefined

錯誤程式碼:

Unhandled rejection TypeError: Cannot set property 'lastIndex' of undefined
    at highlight (/Users/leesin/Desktop/blog/node_modules/highlight.js/lib/highlight.js:511:35)
    at /Users/leesin/Desktop/blog/node_modules/highlight.js/lib/highlight.js:561:21
    at Array.forEach (<anonymous>)
    at Object.
highlightAuto (/Users/leesin/Desktop/blog/node_modules/highlight.js/lib/highlight.js:560:40) at /Users/leesin/Desktop/blog/node_modules/hexo-util/lib/highlight.js:117:25 at highlight (/Users/leesin/Desktop/blog/node_modules/hexo-util/lib/highlight.js:120:7) at highlightUtil (/Users/leesin/Desktop/blog/node_modules/hexo-
util/lib/highlight.js:22:14) at /Users/leesin/Desktop/blog/node_modules/hexo/lib/plugins/filter/before_post_render/backtick_code_block.js:62:15 at String.replace (<anonymous>) at Hexo.backtickCodeBlock (/Users/leesin/Desktop/blog/node_modules/hexo/lib/plugins/filter/before_post_render/backtick_code_block.
js:14:31) at Hexo.tryCatcher (/Users/leesin/Desktop/blog/node_modules/bluebird/js/release/util.js:16:23) at Hexo.<anonymous> (/Users/leesin/Desktop/blog/node_modules/bluebird/js/release/method.js:15:34) at Promise.each.filter (/Users/leesin/Desktop/blog/node_modules/hexo/lib/extend/filter.js:63:65) at tryCatcher (/Users/leesin/Desktop/blog/node_modules/bluebird/js/release/util.js:16:23) at Object.gotValue (/Users/leesin/Desktop/blog/node_modules/bluebird/js/release/reduce.js:155:18) at Object.gotAccum (/Users/leesin/Desktop/blog/node_modules/bluebird/js/release/reduce.js:144:25) at Object.tryCatcher (/Users/leesin/Desktop/blog/node_modules/bluebird/js/release/util.js:16:23) at Promise._settlePromiseFromHandler (/Users/leesin/Desktop/blog/node_modules/bluebird/js/release/promise.js:512:31) at Promise._settlePromise (/Users/leesin/Desktop/blog/node_modules/bluebird/js/release/promise.js:569:18) at Promise._settlePromiseCtx (/Users/leesin/Desktop/blog/node_modules/bluebird/js/release/promise.js:606:10) at _drainQueueStep (/Users/leesin/Desktop/blog/node_modules/bluebird/js/release/async.js:142:12) at _drainQueue (/Users/leesin/Desktop/blog/node_modules/bluebird/js/release/async.js:131:9) Unhandled rejection TypeError: Cannot set property 'lastIndex' of undefined at highlight (/Users/leesin/Desktop/blog/node_modules/highlight.js/lib/highlight.js:511:35) at /Users/leesin/Desktop/blog/node_modules/highlight.js/lib/highlight.js:561:21 at Array.forEach (<anonymous>) at Object.highlightAuto (/Users/leesin/Desktop/blog/node_modules/highlight.js/lib/highlight.js:560:40) at /Users/leesin/Desktop/blog/node_modules/hexo-util/lib/highlight.js:117:25 at highlight (/Users/leesin/Desktop/blog/node_modules/hexo-util/lib/highlight.js:120:7) at highlightUtil (/Users/leesin/Desktop/blog/node_modules/hexo-util/lib/highlight.js:22:14) at /Users/leesin/Desktop/blog/node_modules/hexo/lib/plugins/filter/before_post_render/backtick_code_block.js:62:15 at String.replace (<anonymous>) at Hexo.backtickCodeBlock (/Users/leesin/Desktop/blog/node_modules/hexo/lib/plugins/filter/before_post_render/backtick_code_block.js:14:31) at Hexo.tryCatcher (/Users/leesin/Desktop/blog/node_modules/bluebird/js/release/util.js:16:23) at Hexo.<anonymous> (/Users/leesin/Desktop/blog/node_modules/bluebird/js/release/method.js:15:34) at Promise.each.filter (/Users/leesin/Desktop/blog/node_modules/hexo/lib/extend/filter.js:63:65) at tryCatcher (/Users/leesin/Desktop/blog/node_modules/bluebird/js/release/util.js:16:23) at Object.gotValue (/Users/leesin/Desktop/blog/node_modules/bluebird/js/release/reduce.js:155:18) at Object.gotAccum (/Users/leesin/Desktop/blog/node_modules/bluebird/js/release/reduce.js:144:25) at Object.tryCatcher (/Users/leesin/Desktop/blog/node_modules/bluebird/js/release/util.js:16:23) at Promise._settlePromiseFromHandler (/Users/leesin/Desktop/blog/node_modules/bluebird/js/release/promise.js:512:31) at Promise._settlePromise (/Users/leesin/Desktop/blog/node_modules/bluebird/js/release/promise.js:569:18) at Promise._settlePromiseCtx (/Users/leesin/Desktop/blog/node_modules/bluebird/js/release/promise.js:606:10) at _drainQueueStep (/Users/leesin/Desktop/blog/node_modules/bluebird/js/release/async.js:142:12) at _drainQueue (/Users/leesin/Desktop/blog/node_modules/bluebird/js/release/async.js:131:9)

解決:

hexo根目錄下面的 auto_detect設定為false
這個配置是用來自動查錯的。

原因:

md文章的格式不對,可是字數很多,錯誤可能是程式碼塊的格式不對,這個時候就把這個配置置為false就行了。