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预览报错 #377

Closed
adbplay opened this issue Jan 30, 2024 · 7 comments
Closed

hexo s预览报错 #377

adbplay opened this issue Jan 30, 2024 · 7 comments

Comments

@adbplay
Copy link

adbplay commented Jan 30, 2024

你好开发者,我在使用主题时发生了错误,确切来说是在执行hexo s预览时发生了错误。说明下,我在生成静态文件之前执行了hexo clean命令,且在hexo g生成静态文件时一切正常,并没有报错,只有在hexo s本地预览,且打开浏览器访问localhost:4000时才会产生一下的错误。
以下是报错信息:

$  blog hexo s
INFO  Validating config
INFO  Welcome to Stellar 1.26.3
DOCS  https://xaoxuu.com/wiki/stellar/
REPO  https://github.com/xaoxuu/hexo-theme-stellar.git
  
INFO  Start processing
INFO  Hexo is running at http://localhost:4000/ . Press Ctrl+C to stop.
ERROR Render HTML failed: index.html
Error: /home/xxxx/xxxx/xxxx/blog/node_modules/hexo-theme-stellar/layout/index.styl:1:9
   1| @import 'partial/*'
--------------^
   2| @import 'tag-plugins/*'
   3| @import 'sidebar/*'
   4| @import 'widgets/*'

failed to locate @import file partial/*.styl

    at Evaluator.visitImport (/home/xxxx/xxxx/xxxx/blog/node_modules/stylus/lib/visitor/evaluator.js:915:21)
    at Visitor.visit (/home/xxxx/xxxx/xxxx/blog/node_modules/stylus/lib/visitor/index.js:28:40)
    at Evaluator.visit (/home/xxxx/xxxx/xxxx/blog/node_modules/stylus/lib/visitor/evaluator.js:160:18)
    at Evaluator.visitRoot (/home/xxxx/xxxx/xxxx/blog/node_modules/stylus/lib/visitor/evaluator.js:707:27)
    at Visitor.visit (/home/xxxx/xxxx/xxxx/blog/node_modules/stylus/lib/visitor/index.js:28:40)
    at Evaluator.visit (/home/xxxx/xxxx/xxxx/blog/node_modules/stylus/lib/visitor/evaluator.js:160:18)
    at Evaluator.evaluate (/home/xxxx/xxxx/xxxx/blog/node_modules/stylus/lib/visitor/evaluator.js:247:15)
    at Renderer.render (/home/xxxx/xxxx/xxxx/blog/node_modules/stylus/lib/renderer.js:86:26)
    at Hexo.stylusFn (/home/xxxx/xxxx/xxxx/blog/node_modules/hexo-renderer-stylus/lib/renderer.js:59:6)
    at Hexo.tryCatcher (/home/xxxx/xxxx/xxxx/blog/node_modules/bluebird/js/release/util.js:16:23)
    at Hexo.ret (eval at makeNodePromisifiedEval (/home/xxxx/npm/node_global/lib/node_modules/hexo-cli/node_modules/bluebird/js/release/promisify.js:184:12), <anonymous>:13:39)
    at /home/xxxx/xxxx/xxxx/blog/node_modules/hexo/lib/hexo/render.js:81:22
    at tryCatcher (/home/xxxx/xxxx/xxxx/blog/node_modules/bluebird/js/release/util.js:16:23)
    at Promise._settlePromiseFromHandler (/home/xxxx/xxxx/xxxx/blog/node_modules/bluebird/js/release/promise.js:547:31)
    at Promise._settlePromise (/home/xxxx/xxxx/xxxx/blog/node_modules/bluebird/js/release/promise.js:604:18)
    at Promise._settlePromiseCtx (/home/xxxx/xxxx/xxxx/blog/node_modules/bluebird/js/release/promise.js:641:10)
    at _drainQueueStep (/home/xxxx/xxxx/xxxx/blog/node_modules/bluebird/js/release/async.js:97:12)
    at _drainQueue (/home/xxxx/xxxx/xxxx/blog/node_modules/bluebird/js/release/async.js:86:9)
    at Async._drainQueues (/home/xxxx/xxxx/xxxx/blog/node_modules/bluebird/js/release/async.js:102:5)
    at Async.drainQueues [as _onImmediate] (/home/xxxx/xxxx/xxxx/blog/node_modules/bluebird/js/release/async.js:15:14)
    at process.processImmediate (node:internal/timers:476:21)
Unhandled rejection Error: /home/xxxx/xxxx/xxxx/blog/node_modules/hexo-theme-stellar/layout/index.styl:1:9
   1| @import 'partial/*'
--------------^
   2| @import 'tag-plugins/*'
   3| @import 'sidebar/*'
   4| @import 'widgets/*'

failed to locate @import file partial/*.styl

    at Evaluator.visitImport (/home/xxxx/xxxx/xxxx/blog/node_modules/stylus/lib/visitor/evaluator.js:915:21)
    at Visitor.visit (/home/xxxx/xxxx/xxxx/blog/node_modules/stylus/lib/visitor/index.js:28:40)
    at Evaluator.visit (/home/xxxx/xxxx/xxxx/blog/node_modules/stylus/lib/visitor/evaluator.js:160:18)
    at Evaluator.visitRoot (/home/xxxx/xxxx/xxxx/blog/node_modules/stylus/lib/visitor/evaluator.js:707:27)
    at Visitor.visit (/home/xxxx/xxxx/xxxx/blog/node_modules/stylus/lib/visitor/index.js:28:40)
    at Evaluator.visit (/home/xxxx/xxxx/xxxx/blog/node_modules/stylus/lib/visitor/evaluator.js:160:18)
    at Evaluator.evaluate (/home/xxxx/xxxx/xxxx/blog/node_modules/stylus/lib/visitor/evaluator.js:247:15)
    at Renderer.render (/home/xxxx/xxxx/xxxx/blog/node_modules/stylus/lib/renderer.js:86:26)
    at Hexo.stylusFn (/home/xxxx/xxxx/xxxx/blog/node_modules/hexo-renderer-stylus/lib/renderer.js:59:6)
    at Hexo.tryCatcher (/home/xxxx/xxxx/xxxx/blog/node_modules/bluebird/js/release/util.js:16:23)
    at Hexo.ret (eval at makeNodePromisifiedEval (/home/xxxx/npm/node_global/lib/node_modules/hexo-cli/node_modules/bluebird/js/release/promisify.js:184:12), <anonymous>:13:39)
    at /home/xxxx/xxxx/xxxx/blog/node_modules/hexo/lib/hexo/render.js:81:22
    at tryCatcher (/home/xxxx/xxxx/xxxx/blog/node_modules/bluebird/js/release/util.js:16:23)
    at Promise._settlePromiseFromHandler (/home/xxxx/xxxx/xxxx/blog/node_modules/bluebird/js/release/promise.js:547:31)
    at Promise._settlePromise (/home/xxxx/xxxx/xxxx/blog/node_modules/bluebird/js/release/promise.js:604:18)
    at Promise._settlePromiseCtx (/home/xxxx/xxxx/xxxx/blog/node_modules/bluebird/js/release/promise.js:641:10)
    at _drainQueueStep (/home/xxxx/xxxx/xxxx/blog/node_modules/bluebird/js/release/async.js:97:12)
    at _drainQueue (/home/xxxx/xxxx/xxxx/blog/node_modules/bluebird/js/release/async.js:86:9)
    at Async._drainQueues (/home/xxxx/xxxx/xxxx/blog/node_modules/bluebird/js/release/async.js:102:5)
    at Async.drainQueues [as _onImmediate] (/home/xxxx/xxxx/xxxx/blog/node_modules/bluebird/js/release/async.js:15:14)
    at process.processImmediate (node:internal/timers:476:21)

^CINFO  Have a nice day

我的环境为下:

{
  'hexo-site': '0.0.0',
  npm: '9.2.0',
  node: '18.19.0',
  acorn: '8.8.1',
  ada: '2.7.2',
  ares: '1.23.0',
  base64: '0.5.0',
  brotli: '1.1.0',
  cjs_module_lexer: '1.2.2',
  cldr: '42.0',
  icu: '72.1',
  llhttp: '6.0.11',
  modules: '108',
  napi: '9',
  nghttp2: '1.58.0',
  openssl: '3.1.4',
  simdutf: '3.2.18',
  tz: '2022e',
  unicode: '15.0',
  uv: '1.46.0',
  uvwasi: '0.0.19',
  v8: '10.2.154.26-node.28',
  zlib: '1.3'
}

我有想过是否是站点配置文件_config.yml中配置了该主题不支持的插件而导致的错误。所以我尝试过将站点配置文件重置为初始状态,再进行hexo cleanhexo ghexo s尝试预览页面效果,但显然还是报错(同上)。所以我想请求您的解答和帮助,感谢!

对了,重新编辑下。之前忘了说明,我尝试过使用npm i hexo-theme-stellargit方式安装主题,都会出现以上错误。

@ericclose
Copy link

#371 #372 同类报错。

layout 文件夹下面都是 *.ejs 文件,而 *.styl 文件则位于 /source/css/* 中。

-- source

不知道什么原因,导致你的目录文件结构乱了。

@xaoxuu
Copy link
Owner

xaoxuu commented Jan 31, 2024

你尝试一下用 GitHub Codespaces 看看会不会报错,那是个与本机隔离的环境,可以用来分析是不是环境影响

@adbplay
Copy link
Author

adbplay commented Feb 1, 2024

你尝试一下用 GitHub Codespaces 看看会不会报错,那是个与本机隔离的环境,可以用来分析是不是环境影响

感谢回复。我在Codespace中尝试过了,一切正常。但是在我的本地环境中还是无法使用。我又尝试了在另外一个目录中新建了一个站点,并安装stellar主题。结果还是像之前那样报错。
我会在稍后尝试重装hexo看能不能解决这个问题,我觉得也有可能是因为我使用是hexo-cli而不是hexo。但说真的我不太清楚这两者的区别。而且我在codespace中尝试了hexo和hexo-cli都是正常的,所以我并不抱期待,但还是试试吧!

@xaoxuu
Copy link
Owner

xaoxuu commented Feb 1, 2024

那问题大概是本机安装了某个全局的功能,会修改主题文件结构。

@adbplay
Copy link
Author

adbplay commented Feb 3, 2024

那问题大概是本机安装了某个全局的功能,会修改主题文件结构。

我放弃了。我可能没有必要执着于本地预览它。除开这个错误,其他的一切都是正常的。生成的静态文件也能正常使用,所以我决定没有必要去深究这个明显是环境影响的问题了。不过还是感谢您的回答和帮助!

@adbplay adbplay closed this as completed Feb 3, 2024
@songtianlun
Copy link
Contributor

在 linux 下遇到了同样的问题:

  • os: archlinux
  • node: v18.18.2
  • hexo:
hexo: 7.2.0
hexo-cli: 4.3.2
os: linux 6.8.7-zen1-1-zen Arch Linux
node: 18.18.2
acorn: 8.10.0
ada: 2.6.0
ares: 1.23.0
brotli: 1.1.0
cldr: 44.0
icu: 74.1
llhttp: 6.0.11
modules: 108
napi: 9
nghttp2: 1.58.0
openssl: 3.1.4
simdutf: 3.2.14
tz: 2023c
undici: 5.26.3
unicode: 15.1
uv: 1.47.0
uvwasi: 0.0.18
v8: 10.2.154.26-node.26
zlib: 1.3

复现方法:

hexo server # 正常
Ctrl-C
hexo server # 异常

解决方法:

hexo server # 正常
Ctrl-C
hexo clean
hexo server # 正常

@xaoxuu
Copy link
Owner

xaoxuu commented Apr 26, 2024

这个问题统一都在这个 issue 中跟进吧:#372 (comment)

Repository owner locked and limited conversation to collaborators Apr 26, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants