hexo报错记录

hexo 升级踩坑。

问题描述

终端执行:

hexo new XXXX

出现报错:

NODE_MODULE_VERSION 48. This version of Node.js requires
Error: The module '/usr/local/lib/node_modules/hexo-cli/node_modules/dtrace-provider/build/Release/DTraceProviderBindings.node'
was compiled against a different Node.js version using
NODE_MODULE_VERSION 48. This version of Node.js requires
NODE_MODULE_VERSION 64. Please try re-compiling or re-installing
the module (for instance, using `npm rebuild` or `npm install`).

其中:Node 10.1.0, npm 5.6.0 , hexo 3.7.1

虽然这样的提示并不影响使用,但是每次都出现这么一长串,真的是有点受不了,于是决定解决它,没成想竟然是个坑。记录下解决过程。

解决方法

按照提示,使用npm rebuild ,rebuild过程中出现了各种报错,最后还输出了这么一句This is probably not a problem with npm, 不是npm,难道是hexo?

随后Google,在hexo issues里找到了这篇#2534。尝试着用里面提到的方法:

rm -rvf node_modules
npm install

npm install时出错,后面我又npm install了一次,OK,没有报错,但是奇怪的是执行hexo g -d 依然会出现上面的报错,说明问题还是没有解决。

于是执行了这样的命令:

npm update hexo
npm update -g hexo-cli

没有报错,应该是OK了,稍稍踏实了,再次执行hexo g -d,结果 还是报错,比上次更为严重:

hexo已经挂了。

显示Cannot find module 'highlight.js/lib/languages/shell' .

既然找不到highlight, 那就安装一个吧!终端执行:

npm install highlight.js --save

出现报错:

node-pre-gyp ERR! Tried to download(404): https://fsevents-binaries.s3-us-west-2.amazonaws.com/v1.1.1/fse-v1.1.1-node-v64-darwin-x64.tar.gz
node-pre-gyp ERR! Pre-built binaries not found for [email protected] and [email protected] (node-v64 ABI) (falling back to source compile with node-gyp)
node-pre-gyp http 404 status code downloading tarball https://fsevents-binaries.s3-us-west-2.amazonaws.com/v1.1.1/fse-v1.1.1-node-v64-darwin-x64.tar.gz

发现fsevents在之前的报错中也有出现过,难道是fsevents与node版本不兼容?Google后找到了这篇:

Install on OS X fails as prebuilt binary seems to be missing from S3

上面提到了1.1.1版本存在bug,升级到1.2+,好,死马当活马医,npm i fsevents ,装了最新的fsevents, 1.2.3.

终端再次执行hexo g -d, OK,没有出现上诉报错了,一切正常!

参考

NODE_MODULE_VERSION 46. This version of Node.js requires NODE_MODULE_VERSION 51. Please try re-compiling or re-installing

Install on OS X fails as prebuilt binary seems to be missing from S3