Candinya / Kratos-Rebirth

一个可爱而现代的 Hexo 主题
GNU General Public License v3.0
609 stars 79 forks source link

Bug 回报:Linux上的谜之启动错误(TypeError: Cannot read properties of undefined (reading 'main')) #171

Closed zh-jp closed 3 months ago

zh-jp commented 1 year ago
  1. 报告前须知
  1. 对Bug的描述: 一模一样的config文件和nodejs版本,但是运行在Linux平台上会概率报错,但landscape主题能正常运行。

  2. 复现Bug的方法: 我在windows上编写并测试了config文件,运行在Linux上会报错,而且不是每次都发生错误。。。之前挂载在上面的时候发生报错,但更换主题为landscape时能运行,切回本主题时居然又能运行了,所以没有太过在意。 但今天故技重施,结果启动不了

  3. 期望的行为: 希望每次能顺利运行,就像Windows上一样!

  4. 相关的截图: image

  5. 运行环境(如果该Bug的产生和环境有关,例如浏览器不兼容导致):

    • 操作系统: Linux
  6. 您的配置文件:

    theme: kratos-rebirth # 大概率运行不了
    theme: landscape # 正常启动
  7. 补充内容: 谢谢作者,拜托!拜托!

ArcticLampyrid commented 1 year ago

一直在Linux镜像下自动构建,未遇到过类似问题 考虑发一下您的具体配置信息吗?

zh-jp commented 1 year ago

版本信息:

Linux version 3.10.0-1160.80.1.el7.x86_64 (mockbuild@kbuilder.bsys.centos.org) (gcc version 4.8.5 20150623 (Red Hat 4.8.5-44) (GCC) ) #1 SMP Tue Nov 8 15:48:59 UTC 2022

内核信息:

Linux VM-12-6-centos 3.10.0-1160.80.1.el7.x86_64 #1 SMP Tue Nov 8 15:48:59 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux

_config.yml

# Hexo Configuration
## Docs: https://hexo.io/docs/configuration.html
## Source: https://github.com/hexojs/hexo/

# Site
title: XXX
subtitle: XXX
description: ''
keywords:
author: zh_jp2022@outlook.com
language: zh-CN
timezone: Asia/Shanghai

# URL
## Set your site url here. For example, if you use GitHub Page, set url as 'https://username.github.io/project'
url: 
permalink: :year/:month/:day/:title/
permalink_defaults:
pretty_urls:
  trailing_index: true # Set to false to remove trailing 'index.html' from permalinks
  trailing_html: true # Set to false to remove trailing '.html' from permalinks

# Directory
source_dir: source
public_dir: public
tag_dir: tags
archive_dir: archives
category_dir: categories
code_dir: downloads/code
i18n_dir: :lang
skip_render:

# Writing
new_post_name: :title.md # File name of new posts
default_layout: post
titlecase: false # Transform title into titlecase
external_link:
  enable: true # Open external links in new tab
  field: site # Apply to the whole site
  exclude: ''
filename_case: 0
render_drafts: false
post_asset_folder: false
relative_link: false
future: true
highlight:
  enable: true
  line_number: true
  auto_detect: false
  tab_replace: ''
  wrap: true
  hljs: false
prismjs:
  enable: false
  preprocess: true
  line_number: true
  tab_replace: ''

# Home page setting
# path: Root path for your blogs index page. (default = '')
# per_page: Posts displayed per page. (0 = disable pagination)
# order_by: Posts order. (Order by date descending by default)
index_generator:
  path: ''
  per_page: 10
  order_by: -date

# Category & Tag
default_category: uncategorized
category_map:
tag_map:

# Metadata elements
## https://developer.mozilla.org/en-US/docs/Web/HTML/Element/meta
meta_generator: true

# Date / Time format
## Hexo uses Moment.js to parse and display date
## You can customize the date format as defined in
## http://momentjs.com/docs/#/displaying/format/
date_format: YYYY-MM-DD
time_format: HH:mm:ss
## updated_option supports 'mtime', 'date', 'empty'
updated_option: 'mtime'

# Pagination
## Set per_page to 0 to disable pagination
per_page: 10
pagination_dir: page

# Include / Exclude file(s)
## include:/exclude: options only apply to the 'source/' folder
include:
exclude:
ignore:

# Extensions
## Plugins: https://hexo.io/plugins/
## Themes: https://hexo.io/themes/
#theme: kratos-rebirth

theme: landscape
# Deployment
## Docs: https://hexo.io/docs/one-command-deployment
deploy:
  type: ''

_config.kratos-rebirth.yml

site_logo: /images/siteLogo.webp
avatarUri: /images/avatar.webp

topMenu:
  - label: 首页
    icon: home
    url: /
  - label: 档案馆
    icon: file
    url: /archives/
  - label: 好伙伴
    icon: pase
    url: /friends/
  - label: 链接
    icon: link
    submenu:
      - label: 作者博客
        url: https://XXXX
      - label: 项目链接
        url: https://github.com/zh-jp

vendors:
  # 常用CDN基地址:
  # https://unpkg.com/
  # https://cdn.jsdelivr.net/npm/

  # 以下一行代码指定 npm cdn 基地址,该 CDN 应该兼容 jsdelivr 使用的路径格式
  # npm_cdn: https://cdn.jsdelivr.net/npm/
  packages:
    hexo-theme-kratos-rebirth: 
      # 以下一行代码用于对某个包单独配置 cdn 基地址,使用 null 表示不从 cdn 获取此包
      # cdn_url: null
      # cdn_url: https://cdn.jsdelivr.net/npm/hexo-theme-kratos-rebirth@latest/
    aplayer:
      # 以下一行代码指定所使用的库版本
      # 默认情况下会使用主题开发组进行开发调试时所使用的版本(通常而言也是最适合的版本)
      # 因此该值不建议修改
      # 
      # 注意:如果选择其他版本,则必须配置 npm_cdn 或 为包单独配置 cdn_url 或 修改 vendors 目录,
      # 这是因为主题自带的库只含有默认版本,必须从 cdn 加载其他版本或由用户手动提供其他版本的相关文件
      #
      # 警告:随意切换版本可能造成主题无法正常工作
      # 
      # version: 1.10.1
      files:
        "dist/APlayer.min.css":
          # 以下代码用于单独对某个文件进行映射,以便于使用不符合 jsdelivr 路径格式的CDN(或其他特殊情形)
          # 使用 null 表示不重定向(默认行为)
          # relocate: null
          # relocate: https://cdn.jsdelivr.net/npm/aplayer@1.10.1/dist/APlayer.min.css

          # 以下代码用于指定 SRI 以增强安全性
          # 注意,仅有部分组件支持 SRI,不支持的组件会忽略此值
          # integrity: sha256-6Y7CJDaltoeNgk+ZftgCD9jLgmGv4xKUo8nQ0HgAwVo=

friends:
  list:
  - name: "猫猫①号"
    bio: "喵~"
    avatar: "../images/avatar.webp"
    link: "https://candinya.com"
  - name: "猫猫②号"
    bio: "喵喵~"
    avatar: "../images/avatar.webp"
    link: "https://candinya.com"
  - name: "猫猫⑨号"
    bio: "咪啪~"
    avatar: "../images/avatar.webp"
    link: "https://candinya.com"

# Post Page 文章页配置
posts:
  show_cc: false
  donate: true
  share: true
  comments: 
    provider: gitalk

gitalk:
  clientID: d36fb9e52XXXXXXXX
  clientSecret: 59a38ceXXXXXXXXX
  repo: gitalk-comments
  owner: zh-jp
  admin: 
    - zh-jp
  distractionFreeMode: false
contact:
  weibo: 
  mail: zh_jp2022@outlook.com 
  twitter:  
  linkedin: 
  telegram: 
  fediverse:
    instance: 
    username: 
  github: zh-jp

timenotice: 
icp: 这是icp的位置
psr: 这是psr的位置
ArcticLampyrid commented 1 year ago

手动添加以下内容到 _config.kratos-rebirth.yml 试试 虽然理论上有默认值才对

jsconfig:
  main:
    cover:
      randomAmount: 20 # 表示从1~20
      baseUrl: null # 使用默认值(不单独配置),将跟随 vendors 中的相关设定选择是否使用 cdn
      filenameTemplate: "thumb_{no}.webp" 
    createTime: "2018/05/06 17:03:12"
    donateBtn: "支持我~"
    scanNotice: "扫一扫,好不好?"
    qr_alipay: "/images/alipayqr.webp"
    qr_wechat: "/images/wechatpayqr.webp"
    siteLeaveEvent: false
    leaveTitle: "{{{(>_<)}}}哦哟,崩溃啦~"
    returnTitle: "(*´∇`*)欸,又好啦~"
    copyrightNotice: "该内容采用 CC BY-NC-SA 4.0 许可协议,著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。"
    expire_day: 30
    topNavScrollToggle: true
zh-jp commented 1 year ago

神了,真的可以(虽然不敢保证下次会不会再犯) 大佬能讲解下原理吗

zh-jp commented 1 year ago

非常感谢您的回复!

ArcticLampyrid commented 1 year ago

报错是缺少xxx配置项,所以加上试试 但理论上 Kratos-Rebirth 目录下还有一个 _config.yml 来做 fallback 才对,具体细节可能需要进一步的分析 您的安装方式是?clone到themes目录下还是通过npm的?

zh-jp commented 1 year ago

使用的npm