执行hexo时的一些报错处理

主要有一下几个报错处理:

  • Uncaught TypeError: Cannot read property ‘addEventListener’ of null
  • 执行hexo algolia时报TypeError: Cannot read property ‘filter’ of undefined
  • 执行hexo algolia时报Error AlgoliaSearchNodeJS.AlgoliaSearchCore
  • 执行hexo g时报Error: Cannot find module DTraceProviderBindings

Uncaught TypeError: Cannot read property ‘addEventListener’ of null

报错信息

1
2
3
4
5
6
(index):1690 Uncaught TypeError: Cannot read property 'addEventListener' of null
at Object.success ((index):1690)
at j (index.js?v=2.1.3:2)
at Object.fireWith [as resolveWith] (index.js?v=2.1.3:2)
at x (index.js?v=2.1.3:4)
at XMLHttpRequest.<anonymous> (index.js?v=2.1.3:4)

修复方法
修改主题配置:
关闭local_search

1
2
3
4
5
6
7
8
# Local search
local_search:
enable: false
# if auto, trigger search by changing input
# if manual, trigger search by pressing enter key or search button
trigger: auto
# show top n results per article, show all results by setting to -1
top_n_per_article: 1

修改站点配置:

1
2
3
4
5
6
7
8
search: true
#search:
# path: search.xml
# field: post
# format: html
# limit: 10000
# filter:
# - title

执行hexo algolia时报TypeError: Cannot read property ‘filter’ of undefined

报错信息

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
FATAL Something's wrong. Maybe you can find the solution here: http://hexo.io/docs/troubleshooting.html
TypeError: Cannot read property 'filter' of undefined
at getFields (/home/work/github/blog/LeungGeorge.github.io/node_modules/hexo-algoliasearch/lib/algolia.js:146:16)
at Hexo.algolia (/home/work/github/blog/LeungGeorge.github.io/node_modules/hexo-algoliasearch/lib/algolia.js:16:16)
at Hexo.tryCatcher (/home/work/github/blog/LeungGeorge.github.io/node_modules/bluebird/js/release/util.js:16:23)
at Hexo.ret (eval at makeNodePromisifiedEval (/usr/local/lib/node_modules/hexo-cli/node_modules/bluebird/js/release/promisify.js:184:12), <anonymous>:13:39)
at /home/work/github/blog/LeungGeorge.github.io/node_modules/hexo/lib/hexo/index.js:195:9
at Promise._execute (/home/work/github/blog/LeungGeorge.github.io/node_modules/bluebird/js/release/debuggability.js:300:9)
at Promise._resolveFromExecutor (/home/work/github/blog/LeungGeorge.github.io/node_modules/bluebird/js/release/promise.js:483:18)
at new Promise (/home/work/github/blog/LeungGeorge.github.io/node_modules/bluebird/js/release/promise.js:79:10)
at Hexo.call (/home/work/github/blog/LeungGeorge.github.io/node_modules/hexo/lib/hexo/index.js:191:10)
at /usr/local/lib/node_modules/hexo-cli/lib/hexo.js:66:17
at tryCatcher (/usr/local/lib/node_modules/hexo-cli/node_modules/bluebird/js/release/util.js:16:23)
at Promise._settlePromiseFromHandler (/usr/local/lib/node_modules/hexo-cli/node_modules/bluebird/js/release/promise.js:512:31)
at Promise._settlePromise (/usr/local/lib/node_modules/hexo-cli/node_modules/bluebird/js/release/promise.js:569:18)
at Promise._settlePromise0 (/usr/local/lib/node_modules/hexo-cli/node_modules/bluebird/js/release/promise.js:614:10)
at Promise._settlePromises (/usr/local/lib/node_modules/hexo-cli/node_modules/bluebird/js/release/promise.js:693:18)
at Async._drainQueue (/usr/local/lib/node_modules/hexo-cli/node_modules/bluebird/js/release/async.js:133:16)
at Async._drainQueues (/usr/local/lib/node_modules/hexo-cli/node_modules/bluebird/js/release/async.js:143:10)
at Immediate.Async.drainQueues (/usr/local/lib/node_modules/hexo-cli/node_modules/bluebird/js/release/async.js:17:14)
at runCallback (timers.js:637:20)
at tryOnImmediate (timers.js:610:5)
at processImmediate [as _immediateCallback] (timers.js:582:5)

修复方法

修改站点配置,修改algolia的filter

1
2
3
algolia:
filter:
- title

执行hexo algolia时报Error AlgoliaSearchNodeJS.AlgoliaSearchCore

报错信息

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
/home/work/github/blog/LeungGeorge.github.io/node_modules/bluebird/js/release/async.js:61
fn = function () { throw arg; };
^
Error
at AlgoliaSearchNodeJS.AlgoliaSearchCore (/home/work/github/blog/LeungGeorge.github.io/node_modules/algoliasearch/src/AlgoliaSearchCore.js:51:11)
at AlgoliaSearchNodeJS.AlgoliaSearch (/home/work/github/blog/LeungGeorge.github.io/node_modules/algoliasearch/src/AlgoliaSearch.js:11:21)
at AlgoliaSearchNodeJS.AlgoliaSearchServer (/home/work/github/blog/LeungGeorge.github.io/node_modules/algoliasearch/src/server/builds/AlgoliaSearchServer.js:17:17)
at new AlgoliaSearchNodeJS (/home/work/github/blog/LeungGeorge.github.io/node_modules/algoliasearch/src/server/builds/node.js:79:23)
at algoliasearch (/home/work/github/blog/LeungGeorge.github.io/node_modules/algoliasearch/src/server/builds/node.js:68:10)
at /home/work/github/blog/LeungGeorge.github.io/node_modules/hexo-algoliasearch/lib/algolia.js:119:18
at tryCatcher (/home/work/github/blog/LeungGeorge.github.io/node_modules/bluebird/js/release/util.js:16:23)
at Promise.successAdapter [as _fulfillmentHandler0] (/home/work/github/blog/LeungGeorge.github.io/node_modules/bluebird/js/release/nodeify.js:22:30)
at Promise._settlePromise (/home/work/github/blog/LeungGeorge.github.io/node_modules/bluebird/js/release/promise.js:566:21)
at Promise._settlePromise0 (/home/work/github/blog/LeungGeorge.github.io/node_modules/bluebird/js/release/promise.js:614:10)
at Promise._settlePromises (/home/work/github/blog/LeungGeorge.github.io/node_modules/bluebird/js/release/promise.js:693:18)
at Async._drainQueue (/home/work/github/blog/LeungGeorge.github.io/node_modules/bluebird/js/release/async.js:133:16)
at Async._drainQueues (/home/work/github/blog/LeungGeorge.github.io/node_modules/bluebird/js/release/async.js:143:10)
at Immediate.Async.drainQueues (/home/work/github/blog/LeungGeorge.github.io/node_modules/bluebird/js/release/async.js:17:14)
at runCallback (timers.js:637:20)
at tryOnImmediate (timers.js:610:5)
at processImmediate [as _immediateCallback] (timers.js:582:5)

修复方法
安装hexo-algolia@0.2.0,再执行hexo algolia就可以了

1
2
3
4
npm install hexo-algolia@0.2.0
hexo clean
hexo g
hexo algolia

执行hexo g时报Error: Cannot find module DTraceProviderBindings

报错信息

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
{ Error: Cannot find module './build/default/DTraceProviderBindings'
at Function.Module._resolveFilename (module.js:472:15)
at Function.Module._load (module.js:420:25)
at Module.require (module.js:500:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/usr/local/lib/node_modules/hexo/node_modules/dtrace-provider/dtrace-provider.js:17:23)
at Module._compile (module.js:573:32)
at Object.Module._extensions..js (module.js:582:10)
at Module.load (module.js:490:32)
at tryModuleLoad (module.js:449:12)
at Function.Module._load (module.js:441:3)
at Module.require (module.js:500:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/usr/local/lib/node_modules/hexo/node_modules/bunyan/lib/bunyan.js:79:18)
at Module._compile (module.js:573:32)
at Object.Module._extensions..js (module.js:582:10)
at Module.load (module.js:490:32) code: 'MODULE_NOT_FOUND' }

解决办法
重装:hexo-cli

1
2
npm uninstall hexo-cli -g  
npm install hexo-cli -g

来源:http://leunggeorge.github.io/

0%