hexo-theme-inside icon indicating copy to clipboard operation
hexo-theme-inside copied to clipboard

本地无法通过hexo s部署页面

Open emptylight370 opened this issue 1 year ago • 1 comments

问题描述

FATAL Something's wrong. Maybe you can find the solution here: https://hexo.io/docs/troubleshooting.html
TypeError: htmlToText.fromString is not a function
    at result.runtime.renderReadingTime (D:\MyPage\node_modules\hexo-theme-inside\lib\config.js:219:24)
    at module.exports (D:\MyPage\node_modules\hexo-theme-inside\lib\filter\post.js:89:25)
    at Hexo.tryCatcher (D:\MyPage\node_modules\bluebird\js\release\util.js:16:23)
    at Hexo.<anonymous> (D:\MyPage\node_modules\bluebird\js\release\method.js:15:34)
    at D:\MyPage\node_modules\hexo\lib\extend\filter.js:67:52
    at tryCatcher (D:\MyPage\node_modules\bluebird\js\release\util.js:16:23)
    at Object.gotValue (D:\MyPage\node_modules\bluebird\js\release\reduce.js:166:18)
    at Object.gotAccum (D:\MyPage\node_modules\bluebird\js\release\reduce.js:155:25)
    at Object.tryCatcher (D:\MyPage\node_modules\bluebird\js\release\util.js:16:23)
    at Promise._settlePromiseFromHandler (D:\MyPage\node_modules\bluebird\js\release\promise.js:547:31)
    at Promise._settlePromise (D:\MyPage\node_modules\bluebird\js\release\promise.js:604:18)
    at Promise._settlePromise0 (D:\MyPage\node_modules\bluebird\js\release\promise.js:649:10)
    at Promise._settlePromises (D:\MyPage\node_modules\bluebird\js\release\promise.js:729:18)
    at _drainQueueStep (D:\MyPage\node_modules\bluebird\js\release\async.js:93:12)
    at _drainQueue (D:\MyPage\node_modules\bluebird\js\release\async.js:86:9)
    at Async._drainQueues (D:\MyPage\node_modules\bluebird\js\release\async.js:102:5)
    at Async.drainQueues [as _onImmediate] (D:\MyPage\node_modules\bluebird\js\release\async.js:15:14)
    at process.processImmediate (node:internal/timers:476:21)

在本地启动hexo服务器时无法使用htmlToText库的fromString函数,已经安装了依赖库,根据VSCode的错误提示还安装了@type/htmltotext,只是代码里不显示提示,实际上部署还是不能获取到fromString。

本地环境

node 18.18.2 hexo 6.3.0 hexo-cli 4.3.1 hexo-theme-inside 2.7.1 html-to-text 9.0.5

补充信息

GitHub Actions没有问题。同样通过npm安装依赖可能是本地有哪里不对吧。

emptylight370 avatar Oct 05 '24 05:10 emptylight370

补充一下,GitHub Actions也不行了

emptylight370 avatar Oct 10 '24 05:10 emptylight370

通过询问GitHub Copilot的方法,得知在htmlToText中已经弃用了fromString方法,改为convert方法即可正常部署。即 https://github.com/ikeq/hexo-theme-inside/blob/30a3c07d94faa5461b0328ac54819165f2b9cc42/lib/config.js#L219-L223 改为

htmlToText.convert(content, {
    ignoreImage: false,
    ignoreHref: true,
    wordwrap: false,
})

emptylight370 avatar Nov 24 '24 13:11 emptylight370