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 | # Deployment |
hexo 小问题
当node 版本过高时会产生以下 Warning[5]
1 | (node:13888) 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 | exports.lineno = null; |
后续问题
结果还是有问题
博客部署出错了 详情如下
1 | FATAL Something's wrong. Maybe you can find the solution here: https://hexo.io/docs/troubleshooting.html |
最终方案
下载一个 nodejs 的 12.x 的版本[8]
再部署就没有任何问题了
还有问题就把高版本的 nodejs 删除[8:1]
Hexo 官方 commands 与 server 文档把
hexo server列为启动本地服务器的命令,并说明它会在本地启动服务、监听文件变化,适合写作时预览:https://hexo.io/docs/commands、https://hexo.io/docs/server。 ↩︎Hexo 官方 commands 文档说明,
hexo new [layout] <title>用于创建新文章或新页面;因此这里的hexo n "文章名称"是hexo new的简写用法:https://hexo.io/docs/commands。 ↩︎Hexo 官方 commands 文档说明,
hexo generate用于生成静态文件,hexo deploy用于部署网站;one-command deployment 文档说明本地一键部署通常依赖已配置的 deploy 插件,例如hexo-deployer-git:https://hexo.io/docs/commands、https://hexo.io/docs/one-command-deployment。 ↩︎Hexo 官方 one-command deployment 文档说明,部署配置写在
_config.yml的deploy字段中,并可配置type、repo、branch等值;GitHub Pages 文档也提醒分支和 Pages 设置需要与实际仓库匹配:https://hexo.io/docs/one-command-deployment、https://hexo.io/docs/github-pages。 ↩︎Stylus GitHub issue #2534 记录了 NodeJS 14 环境下启动时出现
Accessing non-existent property 'lineno'、column、filename这组 warning 的问题;这能支撑原文中的 warning 现象,但它是特定依赖和 Node 版本组合下的排障线索:https://github.com/stylus/stylus/issues/2534。 ↩︎该链接指向 Stylus 仓库的 issue #2534,标题为 NodeJS 14 warnings,创建于 2020-05-04,issue 正文包含与原文相同的 circular dependency warning 文本:https://github.com/stylus/stylus/issues/2534。 ↩︎
这类直接修改
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-json、https://docs.npmjs.com/cli/v11/commands/npm-ci、https://hexo.io/docs/troubleshooting。 ↩︎这段是 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-releases、https://hexo.io/docs/troubleshooting。 ↩︎ ↩︎