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

fix: TypeError: require(...) is not a function when setup #1102

Merged
merged 4 commits into from
Nov 18, 2022

Conversation

GZTimeWalker
Copy link
Contributor

Problems

After upgrade to a newer version of hexo and nodejs, const logger = require('hexo-log')() is not available anymore. Consider using const logger = hexo.log to avoid the following error:

INFO  Validating config
ERROR Script load failed: node_modules/hexo-theme-butterfly/scripts/events/init.js
TypeError: require(...) is not a function
    at /Users/gztime/Projects/BLOG/node_modules/hexo-theme-butterfly/scripts/events/init.js:1:100
    at /Users/gztime/Projects/BLOG/node_modules/.pnpm/hexo@6.3.0/node_modules/hexo/lib/hexo/index.js:305:14
    ...
ERROR Script load failed: node_modules/hexo-theme-butterfly/scripts/events/welcome.js
TypeError: require(...) is not a function
    at /Users/gztime/Projects/BLOG/node_modules/hexo-theme-butterfly/scripts/events/welcome.js:1:16
    at /Users/gztime/Projects/BLOG/node_modules/.pnpm/hexo@6.3.0/node_modules/hexo/lib/hexo/index.js:305:14
    ...

@jerryc127
Copy link
Owner

我也是最新版
我怎么没报错
你用的是哪个版本

@GZTimeWalker
Copy link
Contributor Author

$ hexo --version
INFO  Validating config
ERROR Script load failed: node_modules/hexo-theme-butterfly/scripts/events/init.js
TypeError: require(...) is not a function
    at /Users/gztime/Projects/BLOG/node_modules/hexo-theme-butterfly/scripts/events/init.js:1:100
    at /Users/gztime/Projects/BLOG/node_modules/.pnpm/hexo@6.3.0/node_modules/hexo/lib/hexo/index.js:305:14
    ...
ERROR Script load failed: node_modules/hexo-theme-butterfly/scripts/events/welcome.js
TypeError: require(...) is not a function
    at /Users/gztime/Projects/BLOG/node_modules/hexo-theme-butterfly/scripts/events/welcome.js:1:100
    at /Users/gztime/Projects/BLOG/node_modules/.pnpm/hexo@6.3.0/node_modules/hexo/lib/hexo/index.js:305:14
    ...
hexo: 6.3.0
hexo-cli: 4.3.0
os: darwin 22.1.0 13.0.1

node: 19.1.0
v8: 10.7.193.20-node.19
uv: 1.44.2
zlib: 1.2.11
brotli: 1.0.9
ares: 1.18.1
modules: 111
nghttp2: 1.50.0
napi: 8
llhttp: 8.1.0
openssl: 1.1.1s
cldr: 41.0
icu: 71.1
tz: 2022a
unicode: 14.0

@jerryc127 jerryc127 merged commit 6c7debf into jerryc127:dev Nov 18, 2022
jerryc127 added a commit that referenced this pull request Nov 18, 2022
feat: 右下角按鈕增加預覽進度顯示
feat: toc可設置是否顯示預覽進度
fix: 修復 TypeError: require(...) is not a function 的報錯 #1102
improvement: 日期設置相對日期時,文章的日期格式和最新評論的日期格式統一為 年月日
@GZTimeWalker GZTimeWalker deleted the patch-1 branch December 25, 2022 05:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants