hexo执行server时报错处理

鸟枪换炮,新换了mac笔记本。配置开发环境配置了两天,在新电脑上使用hexo构建博客的时候执行hexo server报错。错误信息如下:

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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
{ Error: Cannot find module './build/Release/DTraceProviderBindings'
at Function.Module._resolveFilename (module.js:543:15)
at Function.Module._load (module.js:470:25)
at Module.require (module.js:593:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (/Users/brucexie/Documents/work/myspace/gitblog/myGithubBlog/node_modules/hexo/node_modules/hexo-log/node_modules/bunyan/node_modules/dtrace-provider/dtrace-provider.js:17:23)
at Module._compile (module.js:649:30)
at Object.Module._extensions..js (module.js:660:10)
at Module.load (module.js:561:32)
at tryModuleLoad (module.js:501:12)
at Function.Module._load (module.js:493:3)
at Module.require (module.js:593:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (/Users/brucexie/Documents/work/myspace/gitblog/myGithubBlog/node_modules/hexo/node_modules/hexo-log/node_modules/bunyan/lib/bunyan.js:79:18)
at Module._compile (module.js:649:30)
at Object.Module._extensions..js (module.js:660:10)
at Module.load (module.js:561:32)
at tryModuleLoad (module.js:501:12)
at Function.Module._load (module.js:493:3)
at Module.require (module.js:593:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (/Users/brucexie/Documents/work/myspace/gitblog/myGithubBlog/node_modules/hexo/node_modules/hexo-log/lib/log.js:3:14)
at Module._compile (module.js:649:30) code: 'MODULE_NOT_FOUND' }
{ Error: Cannot find module './build/default/DTraceProviderBindings'
at Function.Module._resolveFilename (module.js:543:15)
at Function.Module._load (module.js:470:25)
at Module.require (module.js:593:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (/Users/brucexie/Documents/work/myspace/gitblog/myGithubBlog/node_modules/hexo/node_modules/hexo-log/node_modules/bunyan/node_modules/dtrace-provider/dtrace-provider.js:17:23)
at Module._compile (module.js:649:30)
at Object.Module._extensions..js (module.js:660:10)
at Module.load (module.js:561:32)
at tryModuleLoad (module.js:501:12)
at Function.Module._load (module.js:493:3)
at Module.require (module.js:593:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (/Users/brucexie/Documents/work/myspace/gitblog/myGithubBlog/node_modules/hexo/node_modules/hexo-log/node_modules/bunyan/lib/bunyan.js:79:18)
at Module._compile (module.js:649:30)
at Object.Module._extensions..js (module.js:660:10)
at Module.load (module.js:561:32)
at tryModuleLoad (module.js:501:12)
at Function.Module._load (module.js:493:3)
at Module.require (module.js:593:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (/Users/brucexie/Documents/work/myspace/gitblog/myGithubBlog/node_modules/hexo/node_modules/hexo-log/lib/log.js:3:14)
at Module._compile (module.js:649:30) code: 'MODULE_NOT_FOUND' }

在百度上搜索了多篇帖子尝试了之后都没有用,执行hexo server还是会报错。解决办法如下:
进入到/Users/brucexie/Documents/work/myspace/gitblog/myGithubBlog/目录,删除node_modules文件夹以及文件夹下面所有的文件,然后执行cnpm(我的hexo是使用淘宝镜像安装的,比原镜像快很多) install就可以解决这个问题了。