修复 Github Action 无法构建 Hexo 博客

挺长时间没有通过 Github Action 编译过 Hexo 博客,为了更好搭配Github Publisher使用,今天重新打开 action,运行过程中报了下面几个错误,导致无法产出正常的静态文件。

问题一:Error: Cannot find module ‘@remy/webmention/lib/webmention’

找不到插件,暂时也没有使用这个插件。直接删除对这个包的依赖。npm uninstall hexo-console-webmention --save

问题二: TypeError: require(…) is not a function

报错:

1
2
3
4
5
6
7
8
[7](https://github.com/xiang578/blog-source/actions/runs/8553722187/job/23437478940#step:9:8)Inferno is in development mode.

[8](https://github.com/xiang578/blog-source/actions/runs/8553722187/job/23437478940#step:9:9)ERROR Script load failed: themes/icarus/scripts/index.js

[9](https://github.com/xiang578/blog-source/actions/runs/8553722187/job/23437478940#step:9:10)TypeError: require(...) is not a function

[10](https://github.com/xiang578/blog-source/actions/runs/8553722187/job/23437478940#step:9:11) at /home/runner/work/blog-source/blog-source/themes/icarus/scripts/index.js:2:35

现在使用主题是 hexo-theme-icarus,开发者今天二月份回复 issues 使用源码安装主题报错 · Issue #1270 · ppoffice/hexo-theme-icarus (github.com)指出 hexo-log 4.0含有不兼容的升级。

问题三:Error: Cannot find module ‘hexo/lib/plugins/helper/date’

旧的依赖已经删除,需要把主题代码中 require('hexo/lib/plugins/helper/date'); 改成 require('hexo/dist/plugins/helper/date');

修复上面三个问题,action 又可以正常生成静态网页。用了 Hexo 快 10 年,经常遇到这些糟心的问题,感觉是时候离开了。

修复 Github Action 无法构建 Hexo 博客

https://blog.xiang578.com/note/fix-github-action-build-error.html

作者

Ryen Xiang

发布于

2024-04-04

更新于

2024-04-19

许可协议


网络回响

评论