将NodeJS和NPM升级到6.2.0和3.9.3后,当我运行hexo d -g
命令更新我的博客时,出现以下错误:
Error: Module version mismatch. Expected 48, got 46.
at Error (native)
at Object.Module._extensions..node (module.js:568:18)
at Module.load (module.js:458:32)
at tryModuleLoad (module.js:417:12)
at Function.Module._load (module.js:409:3)
at Module.require (module.js:468:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/usr/local/lib/node_modules/hexo-cli/node_modules/dtrace-provider/dtrace-provider.js:17:23)
at Module._compile (module.js:541:32)
at Object.Module._extensions..js (module.js:550:10)
at Module.load (module.js:458:32)
at tryModuleLoad (module.js:417:12)
at Function.Module._load (module.js:409:3)
at Module.require (module.js:468:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/usr/local/lib/node_modules/hexo-cli/node_modules/bunyan/lib/bunyan.js:79:18)
{ Error: Cannot find module './build/default/DTraceProviderBindings'
at Function.Module._resolveFilename (module.js:440:15)
at Function.Module._load (module.js:388:25)
at Module.require (module.js:468:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/usr/local/lib/node_modules/hexo-cli/node_modules/dtrace-provider/dtrace-provider.js:17:23)
at Module._compile (module.js:541:32)
at Object.Module._extensions..js (module.js:550:10)
at Module.load (module.js:458:32)
at tryModuleLoad (module.js:417:12)
at Function.Module._load (module.js:409:3)
at Module.require (module.js:468:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/usr/local/lib/node_modules/hexo-cli/node_modules/bunyan/lib/bunyan.js:79:18)
at Module._compile (module.js:541:32)
at Object.Module._extensions..js (module.js:550:10)
at Module.load (module.js:458:32) code: 'MODULE_NOT_FOUND' }
{ Error: Cannot find module './build/Debug/DTraceProviderBindings'
at Function.Module._resolveFilename (module.js:440:15)
at Function.Module._load (module.js:388:25)
at Module.require (module.js:468:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/usr/local/lib/node_modules/hexo-cli/node_modules/dtrace-provider/dtrace-provider.js:17:23)
at Module._compile (module.js:541:32)
at Object.Module._extensions..js (module.js:550:10)
at Module.load (module.js:458:32)
at tryModuleLoad (module.js:417:12)
at Function.Module._load (module.js:409:3)
at Module.require (module.js:468:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/usr/local/lib/node_modules/hexo-cli/node_modules/bunyan/lib/bunyan.js:79:18)
at Module._compile (module.js:541:32)
at Object.Module._extensions..js (module.js:550:10)
at Module.load (module.js:458:32) code: 'MODULE_NOT_FOUND' }
(node) v8::ObjectTemplate::Set() with non-primitive values is deprecated
(node) and will stop working in the next major release.
我想可能会升级Node.js并重新安装node_modules
。
我尝试了rm -rf node_modules && npm install
,但它不起作用。我还尝试了sudo npm i -g npm
然后npm install hexo --no-optional --save
,这两种方法都不起作用。
任何建议都会受到最高的赞赏。
答案 0 :(得分:3)
实际上,在升级节点之后,您安装的软件包会针对旧版本进行编译,并且需要重建它们。无需删除node_modules,也无需运行npm update。
跑步:
npm rebuild
答案 1 :(得分:2)
Hexo似乎不适用于最新版本的节点6.2.0。您应该使用node-v4.4.5(LTS)一段时间,这是大多数用户的推荐版本。
答案 2 :(得分:0)
看起来hexo
是全局安装的软件包,但您只在本地重新安装它。尝试全局重新安装:
npm install hexo -g
答案 3 :(得分:0)
也许您的全局安装文件尚未更新,请尝试使用以下命令更新您的hexo-cli:
"^(.(?![{][{]))+[^{]".r
解决了我的问题。