Closed allen108108 closed 2 years ago
Thanks for opening this issue, maintainers will get back to you as soon as possible!
安裝 hexo-renderer-swig
npm i hexo-renderer-swig
非常感謝回復,但我嘗試過後看起來 package 有點問題
npm WARN deprecated swig@1.4.2: This package is no longer maintained
added 17 packages, and audited 216 packages in 6s
13 packages are looking for funding
run `npm fund` for details
7 low severity vulnerabilities
To address issues that do not require attention, run:
npm audit fix
Some issues need review, and may require choosing
a different dependency.
Run `npm audit` for details.
且 hexo server
仍呈現一樣的畫面
那再安裝 hexo-renderer-njk 試試
npm i hexo-renderer-njk
另外 Hexo Configuration 中的
Plugins: hexo-generator-sitemap
可以刪去,所有 plugins 會按照 package.json
的 dependency
部分加載
8.7.0
应该也不是 swig 的了。但 njk 不是应该包含在 Hexo 里面的吗?
是不是手动改过 theme 文件?
@ljcbaby 您好,theme 我是直接 git 下來的,只有改過幾個無關緊要的設定檔內容,我也不知道為何會變成這樣
@stevenjoezhang 不好意思一直麻煩您,我按照您的方式進行 npm i hexo-renderer-njk 仍然會出現
up to date, audited 407 packages in 1s
13 packages are looking for funding
run `npm fund` for details
16 vulnerabilities (9 low, 7 moderate)
To address issues that do not require attention, run:
npm audit fix
Some issues need review, and may require choosing
a different dependency.
Run `npm audit` for details.
利用 npm audit fix
出現以下 report
up to date, audited 407 packages in 7s
13 packages are looking for funding
run `npm fund` for details
# npm audit report
braces <2.3.1
Regular Expression Denial of Service - https://npmjs.com/advisories/786
No fix available
node_modules/hexo-renderer-njk/node_modules/braces
micromatch 0.2.0 - 2.3.11
Depends on vulnerable versions of braces
Depends on vulnerable versions of parse-glob
node_modules/hexo-renderer-njk/node_modules/micromatch
anymatch 1.2.0 - 1.3.2
Depends on vulnerable versions of micromatch
node_modules/hexo-renderer-njk/node_modules/anymatch
chokidar 1.0.0-rc1 - 2.1.8
Depends on vulnerable versions of anymatch
Depends on vulnerable versions of glob-parent
node_modules/hexo-renderer-njk/node_modules/chokidar
nunjucks 1.0.2 - 1.0.3 || 2.0.0 - 3.2.0
Depends on vulnerable versions of chokidar
node_modules/hexo-renderer-njk/node_modules/nunjucks
hexo-renderer-njk *
Depends on vulnerable versions of nunjucks
node_modules/hexo-renderer-njk
glob-parent <5.1.2
Severity: moderate
Regular expression denial of service - https://npmjs.com/advisories/1751
No fix available
node_modules/glob-base/node_modules/glob-parent
node_modules/hexo-renderer-njk/node_modules/glob-parent
chokidar 1.0.0-rc1 - 2.1.8
Depends on vulnerable versions of anymatch
Depends on vulnerable versions of glob-parent
node_modules/hexo-renderer-njk/node_modules/chokidar
nunjucks 1.0.2 - 1.0.3 || 2.0.0 - 3.2.0
Depends on vulnerable versions of chokidar
node_modules/hexo-renderer-njk/node_modules/nunjucks
hexo-renderer-njk *
Depends on vulnerable versions of nunjucks
node_modules/hexo-renderer-njk
glob-base *
Depends on vulnerable versions of glob-parent
node_modules/glob-base
parse-glob >=2.1.0
Depends on vulnerable versions of glob-base
node_modules/parse-glob
micromatch 0.2.0 - 2.3.11
Depends on vulnerable versions of braces
Depends on vulnerable versions of parse-glob
node_modules/hexo-renderer-njk/node_modules/micromatch
anymatch 1.2.0 - 1.3.2
Depends on vulnerable versions of micromatch
node_modules/hexo-renderer-njk/node_modules/anymatch
markdown *
Regular Expression Denial of Service - https://npmjs.com/advisories/1330
fix available via `npm audit fix`
node_modules/markdown
swig-extras *
Depends on vulnerable versions of markdown
node_modules/swig-extras
minimist <0.2.1 || >=1.0.0 <1.2.3
Prototype Pollution - https://npmjs.com/advisories/1179
fix available via `npm audit fix`
node_modules/optimist/node_modules/minimist
optimist >=0.6.0
Depends on vulnerable versions of minimist
node_modules/optimist
uglify-js <2.6.0
Regular Expression Denial of Service - https://npmjs.com/advisories/48
No fix available
node_modules/uglify-js
swig >=1.0.0-pre1
Depends on vulnerable versions of uglify-js
node_modules/swig
hexo-renderer-swig *
Depends on vulnerable versions of swig
node_modules/hexo-renderer-swig
16 vulnerabilities (9 low, 7 moderate)
To address issues that do not require attention, run:
npm audit fix
Some issues need review, and may require choosing
a different dependency.
若進行 hexo g
會出現非常多的 ERROR Template render error
擷取其中一部分如下 :
ERROR Template render error: (C:\pythonwork\blog\math-py\themes\next\layout\page.njk)
Template render error: (C:\pythonwork\blog\math-py\themes\next\layout\page.njk)
Template render error: (C:\pythonwork\blog\math-py\themes\next\layout\page.njk) [Line 9, Column 41]
Template render error: (C:\pythonwork\blog\math-py\themes\next\layout\page.njk)
Template render error: (C:\pythonwork\blog\math-py\themes\next\layout\_partials\head\head-unique.njk) [Line 13, Column 10]
Template render error: (C:\pythonwork\blog\math-py\themes\next\layout\page.njk)
Template render error: (C:\pythonwork\blog\math-py\themes\next\layout\page.njk)
Template render error: (C:\pythonwork\blog\math-py\themes\next\layout\_partials\header\index.njk) [Line 2, Column 8]
Template render error: (C:\pythonwork\blog\math-py\themes\next\layout\_partials\header\menu.njk)
Template render error: (C:\pythonwork\blog\math-py\themes\next\layout\_partials\header\menu.njk) [Line 27, Column 77]
unexpected token: }}
at Object.exports.prettifyError (C:\pythonwork\blog\math-py\node_modules\hexo-renderer-njk\node_modules\nunjucks\src\lib.js:34:15)
at C:\pythonwork\blog\math-py\node_modules\hexo-renderer-njk\node_modules\nunjucks\src\environment.js:486:31
at new_cls.root [as rootRenderFunc] (eval at _compile (C:\pythonwork\blog\math-py\node_modules\hexo-renderer-njk\node_modules\nunjucks\src\environment.js:565:24), <anonymous>:45:3)
at new_cls.render (C:\pythonwork\blog\math-py\node_modules\hexo-renderer-njk\node_modules\nunjucks\src\environment.js:479:15)
at C:\pythonwork\blog\math-py\node_modules\hexo-renderer-njk\lib\renderer.js:20:38
at _View._compiled (C:\pythonwork\blog\math-py\node_modules\hexo\lib\theme\view.js:136:50)
at _View.render (C:\pythonwork\blog\math-py\node_modules\hexo\lib\theme\view.js:39:17)
at C:\pythonwork\blog\math-py\node_modules\hexo\lib\hexo\index.js:64:21
at tryCatcher (C:\pythonwork\blog\math-py\node_modules\bluebird\js\release\util.js:16:23)
at C:\pythonwork\blog\math-py\node_modules\bluebird\js\release\method.js:15:34
at RouteStream._read (C:\pythonwork\blog\math-py\node_modules\hexo\lib\hexo\router.js:47:5)
at RouteStream.Readable.read (node:internal/streams/readable:487:10)
at resume_ (node:internal/streams/readable:988:12)
at processTicksAndRejections (node:internal/process/task_queues:83:21)
你修改了哪些文件,现在是不推荐直接修改主题文件的,容易影响到后续的更新
而且从你提供的信息来看你是通过 npm 安装的主题啊
@ljcbaby 抱歉,說的不夠清楚,我這邊僅有修改 _config.yml 裡面的選項
# Schemes
# scheme: Muse
#scheme: Mist
#scheme: Pisces
scheme: Gemini
creative_commons:
# Available values: by | by-nc | by-nc-nd | by-nc-sa | by-nd | by-sa | cc-zero
license: by-nc-sa
# Available values: big | small
size: small
sidebar: false
post: true
# You can set a language value if you prefer a translated version of CC license, e.g. deed.zh
# CC licenses are available in 39 languages, you can find the specific and correct abbreviation you need on https://creativecommons.org
language: deed.zh_TW
其他我都沒有動到~
配置文件推荐参考这个:https://theme-next.js.org/docs/getting-started/configuration.html#config-name-yml 也是不推荐直接修改的
這個部份我也有試過,但仍然出現一樣的狀況~
@allen108108 你现在需要先确认安装方式,是 git 还是 npm ,如果两者都有的话可能要先清理一种
@ljcbaby 感謝您的建議,我目前把 git 的部分進行刪除,僅保留npm 的 hexo-theme-next ,的確,應該要先將環境確認,不然會有點混亂。這是我的疏忽。
目前僅保留 hexo-theme-next 仍然出現一樣的情況 進行 hexo g 會出現非常多的 ERROR Template render error
本地测试了一下,你可以用 n
先把 node 降到最新的 LTS 版本,再删除 node_modules
,重新 npm i
,安装依赖试试
js-yaml
hexo-renderer-njk
hexo-renderer-swig
可以先 un
掉
感謝 @ljcbaby 的耐心指導
我安裝了最新的 LTS 版本 14.17.5 並且刪除所有 node_module 之後再重新 npm install
但仍然會出現 ERROR Template render error
现在 npm audit fix
报什么?
ERROR Template render error
也看一下
npm audit fix
:
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@2.3.2 (node_modules\chokidar\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.3.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.13 (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.13: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
up to date in 1.21s
13 packages are looking for funding
run `npm fund` for details
fixed 0 of 3 vulnerabilities in 393 scanned packages
3 vulnerabilities required manual review and could not be updated
ERROR Template render error
其中一項 ( 看似沒有變化 ) :
INFO Files loaded in 862 ms
ERROR Template render error: (C:\pythonwork\blog\math-py\node_modules\hexo-theme-next\layout\page.njk)
Template render error: (C:\pythonwork\blog\math-py\node_modules\hexo-theme-next\layout\page.njk)
Template render error: (C:\pythonwork\blog\math-py\node_modules\hexo-theme-next\layout\page.njk) [Line 9, Column 41]
Template render error: (C:\pythonwork\blog\math-py\node_modules\hexo-theme-next\layout\page.njk)
Template render error: (C:\pythonwork\blog\math-py\node_modules\hexo-theme-next\layout\_partials\head\head-unique.njk) [Line 13, Column 10]
Template render error: (C:\pythonwork\blog\math-py\node_modules\hexo-theme-next\layout\page.njk)
Template render error: (C:\pythonwork\blog\math-py\node_modules\hexo-theme-next\layout\page.njk)
Template render error: (C:\pythonwork\blog\math-py\node_modules\hexo-theme-next\layout\_partials\header\index.njk) [Line 2, Column 8]
Template render error: (C:\pythonwork\blog\math-py\node_modules\hexo-theme-next\layout\_partials\header\menu.njk)
Template render error: (C:\pythonwork\blog\math-py\node_modules\hexo-theme-next\layout\_partials\header\menu.njk) [Line 27, Column 77]
unexpected token: }}
at Object.exports.prettifyError (C:\pythonwork\blog\math-py\node_modules\hexo-renderer-njk\node_modules\nunjucks\src\lib.js:34:15)
at C:\pythonwork\blog\math-py\node_modules\hexo-renderer-njk\node_modules\nunjucks\src\environment.js:486:31
at new_cls.root [as rootRenderFunc] (eval at _compile (C:\pythonwork\blog\math-py\node_modules\hexo-renderer-njk\node_modules\nunjucks\src\environment.js:565:24), <anonymous>:45:3)
at new_cls.render (C:\pythonwork\blog\math-py\node_modules\hexo-renderer-njk\node_modules\nunjucks\src\environment.js:479:15)
at C:\pythonwork\blog\math-py\node_modules\hexo-renderer-njk\lib\renderer.js:20:38
at _View._compiled (C:\pythonwork\blog\math-py\node_modules\hexo\lib\theme\view.js:136:50)
at _View.render (C:\pythonwork\blog\math-py\node_modules\hexo\lib\theme\view.js:39:17)
at C:\pythonwork\blog\math-py\node_modules\hexo\lib\hexo\index.js:64:21
at tryCatcher (C:\pythonwork\blog\math-py\node_modules\bluebird\js\release\util.js:16:23)
at C:\pythonwork\blog\math-py\node_modules\bluebird\js\release\method.js:15:34
at RouteStream._read (C:\pythonwork\blog\math-py\node_modules\hexo\lib\hexo\router.js:47:5)
at RouteStream.Readable.read (internal/streams/readable.js:462:10)
at resume_ (internal/streams/readable.js:958:12)
at processTicksAndRejections (internal/process/task_queues.js:82:21)
js-yaml
hexo-renderer-njk
hexo-renderer-swig
可以先 un
掉试试
un
掉之後,hexo clean
hexo g
不會有 ERROR Template render error 出現了 ( !!!! )
但問題會回到 hexo server
最初的問題 在 render 時瀏覽器會出現
{{ partial('_partials/head/head.njk', {}, {cache: theme.cache.enable}) }}{{ open_graph() }} {{ next_data('page', next_config_unique()) }} {{ next_data('calendar', theme.calendar if page.type === 'schedule' and not page.title else '') }} {{ partial('_third-party/analytics/index.njk', {}, {cache: theme.cache.enable}) }} {{- next_inject('head') }}
{{ partial('_partials/header/brand.njk', {}, {cache: theme.cache.enable}) }} {{ partial('_partials/header/menu.njk', {}, {cache: theme.cache.enable}) }} {{ partial('_partials/search/index.njk', {}, {cache: theme.cache.enable}) }} {{- next_inject('header') }}
{{ sidebar_template.render(false) }}
{{ partial('_partials/widgets.njk', {}, {cache: theme.cache.enable}) }}
{{ partial('_macro/post.njk', {post: post, is_index: true}) }} {{ partial('_macro/post.njk', {post: post, is_index: true}) }} {{ partial('_macro/post.njk', {post: post, is_index: true}) }} {{ partial('_macro/post.njk', {post: post, is_index: true}) }} {{ partial('_macro/post.njk', {post: post, is_index: true}) }} {{ partial('_macro/post.njk', {post: post, is_index: true}) }} {{ partial('_macro/post.njk', {post: post, is_index: true}) }} {{ partial('_macro/post.njk', {post: post, is_index: true}) }} {{ partial('_macro/post.njk', {post: post, is_index: true}) }} {{ partial('_macro/post.njk', {post: post, is_index: true}) }}
{{ paginator({ prev_text: '', next_text: '', mid_size : 1, escape : false }) }}
{{ partial('_partials/footer.njk', {}, {cache: theme.cache.enable}) }}
{{ partial('_scripts/index.njk', {}, {cache: theme.cache.enable}) }} {{ partial('_third-party/index.njk', {}, {cache: theme.cache.enable}) }} {{ partial('_third-party/statistics/index.njk', {}, {cache: theme.cache.enable}) }} {{- next_inject('bodyEnd') }}
更新一下依赖版本试试,用 npm-check-updates
我看你好几个依赖版本都好旧
以下是我的 package.json
:
{
"name": "hexo-site",
"version": "0.0.0",
"private": true,
"scripts": {
"build": "hexo generate",
"clean": "hexo clean",
"deploy": "hexo deploy"
},
"hexo": {
"version": "5.4.0"
},
"dependencies": {
"hexo": "^5.4.0",
"hexo-deployer-cos-cdn": "^1.7.1",
"hexo-deployer-git": "^3.0.0",
"hexo-filter-mathjax": "^0.7.1",
"hexo-generator-archive": "^1.0.0",
"hexo-generator-baidu-sitemap": "^0.1.9",
"hexo-generator-feed": "^3.0.0",
"hexo-generator-index": "^2.0.0",
"hexo-generator-search": "^2.4.3",
"hexo-generator-sitemap": "^2.1.0",
"hexo-generator-tag": "^1.0.0",
"hexo-neat": "^1.0.9",
"hexo-next-twikoo": "^1.0.1",
"hexo-pangu": "^0.2.0",
"hexo-renderer-ejs": "^1.0.0",
"hexo-renderer-marked": "^4.1.0",
"hexo-renderer-stylus": "^2.0.1"
}
}
感謝建議,已更新
{
"name": "hexo-site",
"version": "0.0.0",
"private": true,
"hexo": {
"version": "5.4.0"
},
"dependencies": {
"chokidar": "^3.5.2",
"hexo": "^5.4.0",
"hexo-deployer-git": "^3.0.0",
"hexo-generator-archive": "^1.0.0",
"hexo-generator-category": "^1.0.0",
"hexo-generator-index": "^2.0.0",
"hexo-generator-sitemap": "^2.1.0",
"hexo-generator-tag": "^1.0.0",
"hexo-renderer-ejs": "^1.0.0",
"hexo-renderer-kramed": "^0.1.4",
"hexo-renderer-stylus": "^2.0.1",
"hexo-server": "^2.0.0",
"hexo-theme-next": "^8.7.0",
"lodash": "^4.17.21",
"nunjucks": "^3.2.3"
}
}
但問題還是存在~
C:\pythonwork\blog\math-py\node_modules\hexo-theme-next\layout\_partials\header\menu.njk
这个文件可以发上来看一下吗?
menu.njk
的內容如下 :
{% import 'menu-item.njk' as menu_item with context %}
{%- if theme.menu or theme.algolia_search.enable or theme.local_search.enable %}
<nav class="site-nav">
<ul class="main-menu menu">
{%- for name, path in theme.menu %}
{%- set respath = path %}
{%- if path == '[object Object]' %}
{# Main Menu (default menu item for Submenu) #}
{%- for subname, subpath in path %}
{%- set itemName = subname | lower %}
{%- set respath = subpath %}
{%- if itemName == 'default' %}
{%- set itemName = name | lower %}
{{ menu_item.render(name, itemName, respath) }}
{%- endif %}
{%- endfor %}
{% else %}
{# Main Menu (standard menu items) #}
{%- set itemName = name | lower %}
{{- menu_item.render(name, itemName, respath) | trim }}
{%- endif %}
{%- endfor %}
{%- if theme.algolia_search.enable or theme.local_search.enable %}
<li class="menu-item menu-item-search">
<a role="button" class="popup-trigger">
{%- if theme.menu_settings.icons %}<i class="fa fa-search fa-fw"></i>{%- endif %}{{ __('menu.search') }}
</a>
</li>
{%- endif %}
</ul>
</nav>
{%- endif %}
無法就原 blog repo 進行平滑升級,今天另外 hexo init
一個新的 blog 資料夾
先將所有環境參數都設定好之後 在一篇一篇文章搬移
目前已經成功升級,這邊就先關了。
謝謝 @ljcbaby 周末持續的協助。
This thread has been automatically locked since there has not been any recent activity after it was closed. It is possible issue was solved or at least outdated. Feel free to open new for related bugs.
Please follow this Issue template to provide relevant information, such as source code repository, website URL and screenshots, which will help us investigate. 请按照此 Issue 模版提供相关信息,例如源码仓库、网站链接和屏幕截图,这将有助于我们进行调查。
Issue Checklist
Expected behavior
hexo server
指令後,原預期應該要呈現我 blog 的畫面,但卻出現一堆文字。 Afterhexo server
, I expected that will show my blog.Actual behavior
Steps to reproduce the behavior
hexo clean
hexo g
hexo server
Environment Information
Node.js and NPM Information
Package dependencies Information
Hexo Configuration
NexT Configuration
Other Information
這次錯誤發生在 node js 不小心進行升級後產生,隨後就將 hexo 跟 next 一併升級到最新版本 但看起來似乎仍然出現問題。