Error: Module version mismatch. Expected 48, got 46.

Hexo 是一个简单地、轻量地、基于Node的一个静态博客框架。 Hexo Admin Plugin 是可以为Hexo提供后台管理的插件,今天安装了一下hexo-admin的修改版:hexo-admin-qiniu
进入之前安装的blog目录

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
$ npm install --save hexo-admin-qiniu
.....

$ hexo server -d
Error: Module version mismatch. Expected 48, got 46.
at Error (native)
at Object.Module._extensions..node (module.js:597:18)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/usr/local/lib/node_modules/hexo-cli/node_modules/hexo-log/node_modules/bunyan/node_modules/dtrace-provider/dtrace-provider.js:17:23)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/usr/local/lib/node_modules/hexo-cli/node_modules/hexo-log/node_modules/bunyan/lib/bunyan.js:79:18)

错误提示模块的版本不匹配,可能是因为hexo版本 与很多模块更新不匹配了,尝试删除所有模块,重新安装无果

$ rm -rf node_modules
$ npm install

所以我们重新安装配置下Hexo,解决方法:执行以下代码:

$ npm install hexo --no-optional
$ npm install hexo-cli -g
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules/hexo-cli/node_modules/bluebird
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules/hexo-cli/node_modules/chalk/node_modules/has-ansi/node_modules/ansi-regex
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules/hexo-cli/node_modules/chalk/node_modules/strip-ansi/node_modules/ansi-regex
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules/hexo-cli/node_modules/hexo-fs/node_modules/chokidar/node_modules/anymatch/node_modules/micromatch/node_modules/arr-diff/node_modules/arr-flatten
....
npm ERR! Darwin 16.6.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "hexo-cli" "-g"
npm ERR! node v6.10.1
npm ERR! npm  v3.10.10
npm ERR! path /usr/local/lib/node_modules/hexo-cli/node_modules/bluebird
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall access

npm ERR! Error: EACCES: permission denied, access '/usr/local/lib/node_modules/hexo-cli/node_modules/bluebird'
npm ERR!     at Error (native)
npm ERR!  { Error: EACCES: permission denied, access '/usr/local/lib/node_modules/hexo-cli/node_modules/bluebird'
npm ERR!     at Error (native)
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   syscall: 'access',
npm ERR!   path: '/usr/local/lib/node_modules/hexo-cli/node_modules/bluebird' }
npm ERR! 
npm ERR! Please try running this command again as root/Administrator.

npm ERR! Please include the following file with any support request:
npm ERR!     /Users/alex/Projects/blog/npm-debug.log

分析错误由于权限问题,重新执行

$ sudo npm install --unsafe-perm --verbose -g hexo
Password:
....

安装完成,执行启动hexo

$ hexo server -d
INFO  Start processing
INFO  Hexo is running at http://localhost:4000/. Press Ctrl+C to stop.

启动正常,浏览器访问:http://localhost:4000/admin 现在可以愉快的写博客了
image.png

Alex.Yao wechat
欢迎您扫一扫上面的微信公众号,订阅我的博客!
坚持原创技术分享,您的支持将鼓励我继续创作!