Hexo: Scripts are not loaded when theme is located in node_modules

Created on 2 Aug 2020  路  4Comments  路  Source: hexojs/hexo

Check List

Please check followings before submitting a new issue.

  • [x] I have already read Docs page & Troubleshooting page
  • [x] I have already searched existing issues and they are not help to me
  • [x] I examined error or warning messages and it's difficult to solve
  • [x] Using the latest version of Hexo (run hexo version to check)
  • [x] Node.js is higher than minimum required version

Expected behavior

When I install a theme with npm (eg: npm i hexo-theme-next), and I use one of its defined "tags" (as of Nunjuck tags), I expect it to be available in my content.

Actual behavior

When I install a theme with npm (eg: npm i hexo-theme-next), and I use one of its defined "tags" (as of Nunjuck tags), and start the development server (hexo server) I face an error which indicates me hexo does not about this "tag".

How to reproduce?

  • Install hexo
  • Install a theme via npm
  • Write an article with a tag (like caniuse tag
  • Face the error:
err: Error [Nunjucks Error]: _posts/blah.md [Line 5, Column 4] unknown block tag: caniuse

Is the problem still there under "Safe mode"?

Yes, because it is related to plugins/themes.

Environment & Settings

Node.js & npm version(node -v && npm -v)

v12.16.0
6.13.4

Your site _config.yml (Optional)

theme: 'hexo-theme-next'
theme_dir: node_modules

Most helpful comment

Replace

theme: 'hexo-theme-next'

With

theme: next

And remove

theme_dir: node_modules

In Hexo _config.yml, then try again.

All 4 comments

Replace

theme: 'hexo-theme-next'

With

theme: next

And remove

theme_dir: node_modules

In Hexo _config.yml, then try again.

Yes indeed, it works!
Thank you for this answer 馃憤

I would not have guessed this by reading the doc.

Question: what if the theme is hosted under an organization name, like @foo/hexo-theme-bar? Or if I want to call it @myuser/hexo-theme?

what if the theme is hosted under an organization name, like @foo/hexo-theme-bar?

Theme hosted under an organization hasn't been supported yet.

Gotcha.

Thanks for answering me 馃憤

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Xuanwo picture Xuanwo  路  42Comments

SukkaW picture SukkaW  路  25Comments

pod4g picture pod4g  路  24Comments

fabien-h picture fabien-h  路  22Comments

ghost picture ghost  路  27Comments