Hexo-小姿势

Hexo 小姿势

在本地启动 hexo server[1]

(ctrl + c 停止)

1
hexo s

创建新的博客文章 new blog[2]

1
hexo n "文章名称"

生成文件并部署至仓库 deploy[3]

1
hexo d

部署的信息在 _config.yml 文件最下的 deploy[4]

// _config.yml 示例 (记得冒号后要有空格)

1
2
3
4
5
6
# Deployment
## Docs: https://hexo.io/docs/deployment.html
deploy:
type: git
repo: https://github.com/Ryuu-64/Ryuu-64.github.io
branch: master

hexo 小问题

当node 版本过高时会产生以下 Warning[5]

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

官方的 issues[6] https://github.com/stylus/stylus/issues/2534

解决方案

不用改变node的版本[7]

找到项目中的此文件: \node_modules\stylus\lib\nodes\index.js 在最前处添加如下代码即可

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

后续问题

结果还是有问题

博客部署出错了 详情如下

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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:1972:10)
at tryCatcher (F:\Users\Ryuu\Documents\GitWork\MyBlog\HexoBlogLib\node_modules\bluebird\js\release\util.js:16:23)
at ret (eval at makeNodePromisifiedEval (F:\Users\Ryuu\Documents\GitWork\MyBlog\HexoBlogLib\node_modules\bluebird\js\release\promisify.js:184:12), <anonymous>:13:39)
at F:\Users\Ryuu\Documents\GitWork\MyBlog\HexoBlogLib\node_modules\hexo-fs\lib\fs.js:144:39
at tryCatcher (F:\Users\Ryuu\Documents\GitWork\MyBlog\HexoBlogLib\node_modules\bluebird\js\release\util.js:16:23)
at Promise._settlePromiseFromHandler (F:\Users\Ryuu\Documents\GitWork\MyBlog\HexoBlogLib\node_modules\bluebird\js\release\promise.js:547:31)
at Promise._settlePromise (F:\Users\Ryuu\Documents\GitWork\MyBlog\HexoBlogLib\node_modules\bluebird\js\release\promise.js:604:18)
at Promise._settlePromise0 (F:\Users\Ryuu\Documents\GitWork\MyBlog\HexoBlogLib\node_modules\bluebird\js\release\promise.js:649:10)
at Promise._settlePromises (F:\Users\Ryuu\Documents\GitWork\MyBlog\HexoBlogLib\node_modules\bluebird\js\release\promise.js:729:18)
at Promise._fulfill (F:\Users\Ryuu\Documents\GitWork\MyBlog\HexoBlogLib\node_modules\bluebird\js\release\promise.js:673:18)
at Promise._resolveCallback (F:\Users\Ryuu\Documents\GitWork\MyBlog\HexoBlogLib\node_modules\bluebird\js\release\promise.js:466:57)
at Promise._settlePromiseFromHandler (F:\Users\Ryuu\Documents\GitWork\MyBlog\HexoBlogLib\node_modules\bluebird\js\release\promise.js:559:17)
at Promise._settlePromise (F:\Users\Ryuu\Documents\GitWork\MyBlog\HexoBlogLib\node_modules\bluebird\js\release\promise.js:604:18)
at Promise._settlePromise0 (F:\Users\Ryuu\Documents\GitWork\MyBlog\HexoBlogLib\node_modules\bluebird\js\release\promise.js:649:10)
at Promise._settlePromises (F:\Users\Ryuu\Documents\GitWork\MyBlog\HexoBlogLib\node_modules\bluebird\js\release\promise.js:729:18)
at Promise._fulfill (F:\Users\Ryuu\Documents\GitWork\MyBlog\HexoBlogLib\node_modules\bluebird\js\release\promise.js:673:18)

最终方案

下载一个 nodejs 的 12.x 的版本[8]

再部署就没有任何问题了

还有问题就把高版本的 nodejs 删除[8:1]


  1. Hexo 官方 commands 与 server 文档把 hexo server 列为启动本地服务器的命令,并说明它会在本地启动服务、监听文件变化,适合写作时预览:https://hexo.io/docs/commandshttps://hexo.io/docs/server↩︎

  2. Hexo 官方 commands 文档说明,hexo new [layout] <title> 用于创建新文章或新页面;因此这里的 hexo n "文章名称"hexo new 的简写用法:https://hexo.io/docs/commands↩︎

  3. Hexo 官方 commands 文档说明,hexo generate 用于生成静态文件,hexo deploy 用于部署网站;one-command deployment 文档说明本地一键部署通常依赖已配置的 deploy 插件,例如 hexo-deployer-githttps://hexo.io/docs/commandshttps://hexo.io/docs/one-command-deployment↩︎

  4. Hexo 官方 one-command deployment 文档说明,部署配置写在 _config.ymldeploy 字段中,并可配置 typerepobranch 等值;GitHub Pages 文档也提醒分支和 Pages 设置需要与实际仓库匹配:https://hexo.io/docs/one-command-deploymenthttps://hexo.io/docs/github-pages↩︎

  5. Stylus GitHub issue #2534 记录了 NodeJS 14 环境下启动时出现 Accessing non-existent property 'lineno'columnfilename 这组 warning 的问题;这能支撑原文中的 warning 现象,但它是特定依赖和 Node 版本组合下的排障线索:https://github.com/stylus/stylus/issues/2534↩︎

  6. 该链接指向 Stylus 仓库的 issue #2534,标题为 NodeJS 14 warnings,创建于 2020-05-04,issue 正文包含与原文相同的 circular dependency warning 文本:https://github.com/stylus/stylus/issues/2534↩︎

  7. 这类直接修改 node_modules/stylus/lib/nodes/index.js 的做法更接近本机临时实验;npm 的 package-lock.json / npm ci 文档强调依赖树和干净安装的可复现性,Hexo troubleshooting 也更适合从版本、配置、插件、主题和错误输出排查,因此长期方案应沉淀为依赖版本、锁文件、升级或可复现补丁,而不是只保留本机手改:https://docs.npmjs.com/cli/v11/configuring-npm/package-lock-jsonhttps://docs.npmjs.com/cli/v11/commands/npm-cihttps://hexo.io/docs/troubleshooting↩︎

  8. 这段是 2021 年上下文中的本机排障经验。Node.js 官方 release 页面按 Current、Active LTS、Maintenance LTS、End-of-life 区分版本状态,并建议生产应用使用 Active LTS 或 Maintenance LTS;因此现代维护时不应默认退回 Node 12.x,而应先核对当前 Hexo / 主题 / 插件支持范围并选择仍受维护的 LTS:https://nodejs.org/en/about/previous-releaseshttps://hexo.io/docs/troubleshooting↩︎ ↩︎