Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
emptylight370 opened this issue Oct 5, 2024 · 2 comments · May be fixed by #348
Open

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

emptylight370 opened this issue Oct 5, 2024 · 2 comments · May be fixed by #348
Labels

Comments

@emptylight370
Copy link

问题描述

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
Copy link
Author

补充一下,GitHub Actions也不行了

@emptylight370
Copy link
Author

通过询问GitHub Copilot的方法,得知在htmlToText中已经弃用了fromString方法,改为convert方法即可正常部署。即

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

改为

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant