Skip to content

hexo g执行时报错TypeError: Cannot read properties of undefined (reading 'plugins') #1746

@mountainmist1

Description

@mountainmist1

Please follow this Issue template to provide relevant information, such as source code repositories, blog links, and screenshots, which will help us investigate.
请按照此 Issue 模版提供相关信息,例如源码仓库、博客链接和屏幕截图,这将有助于我们进行调查。

Issue Checklist

  • I am using the latest version of NexT.
  • I have read the relevant documents of Hexo and NexT.
  • I have reviewed the latest Roadmap on GitHub and searched for current issues, which does not help me.

Expected behavior

Actual behavior

Steps to reproduce the behavior

  1. N/A
  2. N/A
  3. N/A

Environment Information

Node.js and NPM Information

v16.20.2
8.19.4

Package dependencies Information

[email protected] /root/blog
├── @next-theme/[email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
└── [email protected]

Hexo Configuration

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

# Site
title: Snowball's Note
subtitle: ''
description: '笔记本'
keywords:
author: Snowball
language: zh-CN
timezone: ''
# canvas_nest: true 
# URL
## If your site is put in a subdirectory, set url as 'http://yoursite.com/child' and root as '/child/'
#url: https://github.com/mountainmist1/mountainmist.github.io
#url: http://www.mountainmist.work/
url: https://www.mountainmist.work/
root: /
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: true
relative_link: false
future: true
highlight:
  enable: true
  line_number: true
  auto_detect: true
  tab_replace: ''
  wrap: true
  hljs: false

# 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: 4
  order_by: -date


tag_generator:
  per_page: 20 #标签页每页博客数
# 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
## Use post's date for updated date unless set in front-matter
use_date_for_updated: false

# Pagination
## Set per_page to 0 to disable pagination
per_page: 4
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: next
#头像是否旋转(如果不要旋转取false)
avatarrotation: true
# Deployment
## Docs: https://hexo.io/docs/deployment.html
deploy:
  type: git
  #repository: [email protected]:mountainmist1/mountainmist.github.io
  repository: [email protected]:/home/git/hexoBlog
  branch: master
jsonContent:
  meta: false
  pages: false
  posts:
    title: true
    date: true
    path: true
    text: false
    raw: false
    content: false
    slug: false
    updated: false
    comments: false
    link: false
    permalink: false
    excerpt: false
    categories: false
    tags: true

# 网站运行时间,格式形如:“本站已安全运行 12 天 11 小时 16 分 31 秒”
# Runing Time
# running_time:
#  enable: true
#  create_time: '04/05/2020 17:38:00' #此处修改你的建站时间或者网站上线时间

archive_generator: #归档页的配置
  per_page: 30 #归档页每页博客数
  yearly: true #按年归档
  monthly: true #按月归档
#标签页的分页设置

search:
  path: search.xml 
  field: post 
  format: html 
  limit: 10000

next/scripts/events/lib/vendors.js

'use strict';

const fs = require('fs');
const path = require('path');
const yaml = require('js-yaml');
const { url_for } = require('hexo-util');
const { getVendors } = require('./utils');

let internal;
try {
  internal = require('@next-theme/plugins');
} catch {
}
const vendorsFile = fs.readFileSync(path.join(__dirname, '../../../_vendors.yml'));
const dependencies = yaml.load(vendorsFile);

module.exports = hexo => {
  const { vendors, creative_commons, pace } = hexo.theme.config;
  if (typeof internal === 'function') {
    internal(hexo, dependencies);
  }
  let { plugins = 'cdnjs' } = vendors;
  if (plugins === 'local' && typeof internal === 'undefined') {
    hexo.log.warn('Dependencies for `plugins: local` not found. The default CDN provider CDNJS is used instead.');
    hexo.log.warn('Run `npm install @next-theme/plugins` in Hexo site root directory to install the plugin.');
    plugins = 'cdnjs';
  }
  for (const [key, value] of Object.entries(dependencies)) {
    // This script will be executed repeatedly when Hexo listens file changes
    // But the variable vendors[key] only needs to be modified once
    if (vendors[key] && typeof vendors[key] === 'string') {
      vendors[key] = {
        url: url_for.call(hexo, vendors[key])
      };
      continue;
    }
    if (key === 'creative_commons') {
      value.file = `${value.dir}/${creative_commons.size}/${creative_commons.license.replace(/-/g, '_')}.svg`;
    }
    if (key === 'pace_css') {
      value.file = `${value.dir}/${pace.color}/pace-theme-${pace.theme}.css`;
    }
    const { name, file } = value;
    const links = getVendors({
      ...value,
      minified: file,
      local   : url_for.call(hexo, `lib/${name}/${file}`),
      custom  : vendors.custom_cdn_url
    });
    vendors[key] = {
      url      : links[plugins] || links.cdnjs,
      integrity: value.integrity
    };
  }
};

Other Information

执行hexo g时报错
Uploading 微信截图_20241220115529.png…

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions