At first, all I want is making the asset folder work, then I tried to update hexo and met a series of problem and got them solved.

Conflication of hexo-generator-feed and hexo 3

Problem

The first problem I met is shown as following

1
2
Template render error: (unknown path) [Line 8, Column 25]
Error: Unable to call `the return value of (posts["first"])["updated"]["toISOString"]`, which is undefined or falsey

Solution

  • I found a issue stating the same problem and it was answered that the plugin hexo-generator-feed and hexo-generator-sitemap is incompatible with Hexo 3

  • someone uninstalls these plugins to solve the problem which doesn't work for me as maupassant-hexo requires hexo-generator-feed.

  • As stated in the hexo-generator-feed repo:
    • Hexo 4: 2.x
    • Hexo 3: 1.x
    • Hexo 2: 0.x
  • While my version in package.json is "hexo": "^3.2.0" and "hexo-generator-feed": "^1.2.2". I am guessing that update hexo and hexo-generator-feed might help solve the problem.
  • And yes, when I have Hexo: 4.2.1 and hexo-generator-feed: 2.2.0, it is solved automatically.
  • npm rebuild node-sass --force.

Updating node and Hexo

Updating Node.js

  • Newer version of node.js is needed for updating Hexo.
  • I forgot how I install my node originally. Here reinstalled it as follows
    1. which node
    2. sudo rm -rf /usr/local/bin/node
    3. sudo rm -rf /usr/loca/lib/node_modules/npm/
    4. brew doctor
    5. brew cleanup --prune-prefix
    6. brew install node
  • Uninstall node.js on OSX.
  • Then I try to make the link use the command brew link node which shed me the error Error: Could not symlink include/node/common.gypi.
  • The solution is here
    1. sudo chown -R $(whoami) /usr/local/*: change the owner of the files (root) to myself $(whoami), otherwise, I couldn't rm .gypi, refer to here and here
    2. rm '/usr/local/include/node/config.gypi'
    3. brew link --overwrite node
  • Then I met the problem when using npm, giving me the error modeule.js:538 throw err;
    • This is solved by reinstalling the node using homebrew.

Update hexo

  • modify the package.json and use the command npm update in the terminal.

Downgrading node

  • When I try to deploy hexo d, it gave me the error TypeError [ERR_INVALID_ARG_TYPE]: The "mode" argument must be integer. Received an instance of Object
  • This is because the version of Node.js is too high and we need to downgrade it.
  • Downgrading through brew
    1. brew unlink node
    2. brew install node@12
    3. brew link node@12: failed
    4. brew link --overwrite node@12

About Node.js & NPM

Node.js

npm

  • node.js package manager.
  • write packages needed into package.json and run npm install or npm update. All the packages are inside node_modules.
  • An alternative: yarn