Hexo: Remove Stylus-Related Warnings

This article chronicles how to remove Stylus-related warnings (see below) with Hexo 6.0.0 & Node.js 14.

1
2
3
4
5
6
7
8
$ hexo -s                              
(node:87224) Warning: Accessing non-existent property 'lineno' of module exports inside circular dependency
(Use `node --trace-warnings ...` to show where the warning was created)
(node:87224) Warning: Accessing non-existent property 'column' of module exports inside circular dependency
(node:87224) Warning: Accessing non-existent property 'filename' of module exports inside circular dependency
(node:87224) Warning: Accessing non-existent property 'lineno' of module exports inside circular dependency
(node:87224) Warning: Accessing non-existent property 'column' of module exports inside circular dependency
(node:87224) Warning: Accessing non-existent property 'filename' of module exports inside circular dependency

First, use --trace-warnings to track down the issue.

1
npx cross-env NODE_OPTIONS="--trace-warnings" hexo s

The output identifies stylus (a dependency of nib) as the culprit.

Add version resolutions to package.json (and preinstall npm-force-resolutions if npm is used). The warnings should just disappear.

1
2
3
4
5
6
"resolutions": {
"stylus": "^0.56.0"
},
"scripts": {
"preinstall": "npx npm-force-resolutions"
}

Reference

  1. 赵一博. 解决Hexo在使用Node.js 14时的「Accessing non-existent property……」问题.