Warning: Accessing non-existent property

复现

使用到本主题或用到了stylus的主题时,执行generate等相关命令,会出现警告如下:

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

原因

hexo使用到了stylus@0.54.5,版本较低,不兼容node-v14及以上版本,详见https://github.com/stylus/stylus/pull/2538

解决方法

该问题在stylus@0.54.8被修复

但hexo内置的nib@1.1.2使用的是stylus@0.54.5,其依赖如下

1
2
└─nib@1.1.2
└─ stylus@0.54.5

nib已修复该问题,但并未提交至npm仓库(nib的npm仓库已经6年未更新)。

可将node_modules-->nib-->node_modules-->stylus-->lib-->nodes-->index.js添加以下内容至文件首,详见:https://github.com/stylus/stylus/pull/2538/commits/16e2a6c6f96f80b0d700411879f1c13991a0a1a5

1
2
3
exports.lineno = null;
exports.column = null;
exports.filename = null;