【hexo】使用 node 14 运行 hexo 报错

Posted by 西维蜀黍 on 2020-06-13, Last Modified on 2021-10-02

Situation

$ hexo g
FATAL Something's wrong. Maybe you can find the solution here: https://hexo.io/docs/troubleshooting.html
TypeError [ERR_INVALID_ARG_TYPE]: The "mode" argument must be integer. Received an instance of Object
    at copyFile (fs.js:1895:10)
    at tryCatcher (/SW/myBlog/node_modules/hexo-deployer-git/node_modules/bluebird/js/release/util.js:16:23)
    at ret (eval at makeNodePromisifiedEval (/usr/local/lib/node_modules/hexo-cli/node_modules/bluebird/js/release/promisify.js:184:12), <anonymous>:13:39)
    at /SW/myBlog/node_modules/hexo-deployer-git/node_modules/hexo-fs/lib/fs.js:144:39
    at tryCatcher (/SW/myBlog/node_modules/hexo-deployer-git/node_modules/bluebird/js/release/util.js:16:23)
    at Promise._settlePromiseFromHandler (/SW/myBlog/node_modules/hexo-deployer-git/node_modules/bluebird/js/release/promise.js:517:31)
    at Promise._settlePromise (/SW/myBlog/node_modules/hexo-deployer-git/node_modules/bluebird/js/release/promise.js:574:18)
    at Promise._settlePromise0 (/SW/myBlog/node_modules/hexo-deployer-git/node_modules/bluebird/js/release/promise.js:619:10)
    at Promise._settlePromises (/SW/myBlog/node_modules/hexo-deployer-git/node_modules/bluebird/js/release/promise.js:699:18)
    at Promise._fulfill (/SW/myBlog/node_modules/hexo-deployer-git/node_modules/bluebird/js/release/promise.js:643:18)
    at Promise._resolveCallback (/SW/myBlog/node_modules/hexo-deployer-git/node_modules/bluebird/js/release/promise.js:437:57)
    at Promise._settlePromiseFromHandler (/SW/myBlog/node_modules/hexo-deployer-git/node_modules/bluebird/js/release/promise.js:529:17)
    at Promise._settlePromise (/SW/myBlog/node_modules/hexo-deployer-git/node_modules/bluebird/js/release/promise.js:574:18)
    at Promise._settlePromise0 (/SW/myBlog/node_modules/hexo-deployer-git/node_modules/bluebird/js/release/promise.js:619:10)
    at Promise._settlePromises (/SW/myBlog/node_modules/hexo-deployer-git/node_modules/bluebird/js/release/promise.js:699:18)
    at Promise._fulfill (/SW/myBlog/node_modules/hexo-deployer-git/node_modules/bluebird/js/release/promise.js:643:18)
    at Promise._resolveCallback (/SW/myBlog/node_modules/hexo-deployer-git/node_modules/bluebird/js/release/promise.js:437:57)
    at Promise._settlePromiseFromHandler (/SW/myBlog/node_modules/hexo-deployer-git/node_modules/bluebird/js/release/promise.js:529:17)
    at Promise._settlePromise (/SW/myBlog/node_modules/hexo-deployer-git/node_modules/bluebird/js/release/promise.js:574:18)
    at Promise._settlePromise0 (/SW/myBlog/node_modules/hexo-deployer-git/node_modules/bluebird/js/release/promise.js:619:10)
    at Promise._settlePromises (/SW/myBlog/node_modules/hexo-deployer-git/node_modules/bluebird/js/release/promise.js:699:18)
    at Promise._fulfill (/SW/myBlog/node_modules/hexo-deployer-git/node_modules/bluebird/js/release/promise.js:643:18)
    at Promise._resolveCallback (/SW/myBlog/node_modules/hexo-deployer-git/node_modules/bluebird/js/release/promise.js:437:57)
    at Promise._settlePromiseFromHandler (/SW/myBlog/node_modules/hexo-deployer-git/node_modules/bluebird/js/release/promise.js:529:17)
    at Promise._settlePromise (/SW/myBlog/node_modules/hexo-deployer-git/node_modules/bluebird/js/release/promise.js:574:18)
    at Promise._settlePromise0 (/SW/myBlog/node_modules/hexo-deployer-git/node_modules/bluebird/js/release/promise.js:619:10)
    at Promise._settlePromises (/SW/myBlog/node_modules/hexo-deployer-git/node_modules/bluebird/js/release/promise.js:699:18)
    at Promise._fulfill (/SW/myBlog/node_modules/hexo-deployer-git/node_modules/bluebird/js/release/promise.js:643:18)
    at /SW/myBlog/node_modules/hexo-deployer-git/node_modules/bluebird/js/release/nodeback.js:42:21
    at FSReqCallback.oncomplete (fs.js:163:23)

Solution

出现这些是因为node版本太高,切换成低版本的node来运行Hexo就可以了。

之前安装的是 node14版本。

$ brew uninstall node

$ brew search node
==> Formulae
libbitcoin-node      node                 node-sass            node@12 ✔            nodebrew             nodenv
llnode               node-build           node@10              node_exporter        nodeenv
==> Casks
nodebox                                                         nodeclipse

If you meant "node" specifically:
It was migrated from homebrew/cask to homebrew/core.
$ brew install node@12
...
$ brew link node@12
$ echo "\n" >> ~/.zshrc; export PATH="/usr/local/opt/node@12/bin:$PATH"