hexojs / hexo

A fast, simple & powerful blog framework, powered by Node.js.
https://hexo.io
MIT License
39.59k stars 4.86k forks source link

YAMLException: Specified list of YAML types (or a single Type object) contains a non-Type object. #4917

Closed noraj closed 1 year ago

noraj commented 2 years ago

I upgraded my hexo dependencies:

 hexo                       ^6.0.0  →  ^6.1.0                                                                                                                                                                                                
 hexo-renderer-markdown-it  ^5.0.0  →  ^6.0.1                                                                                                                                                                                                
 hexo-server                ^2.0.0  →  ^3.0.0

Check List

Expected behavior

Normal generation with hexo g.

Actual behavior

$ hexo g
YAMLException: Specified list of YAML types (or a single Type object) contains a non-Type object.
    at /home/noraj/Dev/hackdoc/node_modules/hexo/node_modules/js-yaml/lib/schema.js:104:13
    at Array.forEach (<anonymous>)
    at Schema.extend (/home/noraj/Dev/hackdoc/node_modules/hexo/node_modules/js-yaml/lib/schema.js:102:12)
    at Object.<anonymous> (/home/noraj/Dev/hackdoc/node_modules/hexo/lib/plugins/renderer/yaml.js:5:36)
    at Module._compile (node:internal/modules/cjs/loader:1097:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1151:10)
    at Module.load (node:internal/modules/cjs/loader:975:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Module.require (node:internal/modules/cjs/loader:999:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at module.exports (/home/noraj/Dev/hackdoc/node_modules/hexo/lib/plugins/renderer/index.js:15:16)
    at Hexo.init (/home/noraj/Dev/hackdoc/node_modules/hexo/lib/hexo/index.js:235:35)
    at /home/noraj/.asdf/installs/nodejs/17.5.0/.npm/lib/node_modules/hexo-cli/lib/hexo.js:49:17
    at tryCatcher (/home/noraj/.asdf/installs/nodejs/17.5.0/.npm/lib/node_modules/hexo-cli/node_modules/bluebird/js/release/util.js:16:23)
    at Promise._settlePromiseFromHandler (/home/noraj/.asdf/installs/nodejs/17.5.0/.npm/lib/node_modules/hexo-cli/node_modules/bluebird/js/release/promise.js:547:31)
    at Promise._settlePromise (/home/noraj/.asdf/installs/nodejs/17.5.0/.npm/lib/node_modules/hexo-cli/node_modules/bluebird/js/release/promise.js:604:18)
    at Promise._settlePromise0 (/home/noraj/.asdf/installs/nodejs/17.5.0/.npm/lib/node_modules/hexo-cli/node_modules/bluebird/js/release/promise.js:649:10)
    at Promise._settlePromises (/home/noraj/.asdf/installs/nodejs/17.5.0/.npm/lib/node_modules/hexo-cli/node_modules/bluebird/js/release/promise.js:729:18)
    at _drainQueueStep (/home/noraj/.asdf/installs/nodejs/17.5.0/.npm/lib/node_modules/hexo-cli/node_modules/bluebird/js/release/async.js:93:12)
    at _drainQueue (/home/noraj/.asdf/installs/nodejs/17.5.0/.npm/lib/node_modules/hexo-cli/node_modules/bluebird/js/release/async.js:86:9)
    at Async._drainQueues (/home/noraj/.asdf/installs/nodejs/17.5.0/.npm/lib/node_modules/hexo-cli/node_modules/bluebird/js/release/async.js:102:5)
    at Immediate.Async.drainQueues [as _onImmediate] (/home/noraj/.asdf/installs/nodejs/17.5.0/.npm/lib/node_modules/hexo-cli/node_modules/bluebird/js/release/async.js:15:14) {
  reason: 'Specified list of YAML types (or a single Type object) contains a non-Type object.',
  mark: undefined
}

It seems this line triggers it:

https://github.com/nodeca/js-yaml/blob/49baadd52af887d2991e2c39a6639baa56d6c71b/lib/schema.js#L104

How to reproduce?

I'm not able to create a minimal reproducible environment. It's especially hard since the error message doesn't tell me which file triggers the error. So I create a private repository with my code by I can only add user one by one as collaborator and not the whole hexojs/core team at once. So please ask me access and I'll add you.

Is the problem still there under "Safe mode"?

Yes it is a dependency of hexo core

$ hexo --safe                                                                                                                                                                                                                              
FATAL YAMLException: Specified list of YAML types (or a single Type object) contains a non-Type object.
    at /home/noraj/Dev/hackdoc/node_modules/hexo/node_modules/js-yaml/lib/schema.js:104:13
    at Array.forEach (<anonymous>)
    at Schema.extend (/home/noraj/Dev/hackdoc/node_modules/hexo/node_modules/js-yaml/lib/schema.js:102:12)
    at Object.<anonymous> (/home/noraj/Dev/hackdoc/node_modules/hexo/lib/plugins/renderer/yaml.js:5:36)
    at Module._compile (node:internal/modules/cjs/loader:1097:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1151:10)
    at Module.load (node:internal/modules/cjs/loader:975:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Module.require (node:internal/modules/cjs/loader:999:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at module.exports (/home/noraj/Dev/hackdoc/node_modules/hexo/lib/plugins/renderer/index.js:15:16)
    at Hexo.init (/home/noraj/Dev/hackdoc/node_modules/hexo/lib/hexo/index.js:235:35)
    at /home/noraj/.asdf/installs/nodejs/17.5.0/.npm/lib/node_modules/hexo-cli/lib/hexo.js:49:17
    at tryCatcher (/home/noraj/.asdf/installs/nodejs/17.5.0/.npm/lib/node_modules/hexo-cli/node_modules/bluebird/js/release/util.js:16:23)
    at Promise._settlePromiseFromHandler (/home/noraj/.asdf/installs/nodejs/17.5.0/.npm/lib/node_modules/hexo-cli/node_modules/bluebird/js/release/promise.js:547:31)
    at Promise._settlePromise (/home/noraj/.asdf/installs/nodejs/17.5.0/.npm/lib/node_modules/hexo-cli/node_modules/bluebird/js/release/promise.js:604:18)
    at Promise._settlePromise0 (/home/noraj/.asdf/installs/nodejs/17.5.0/.npm/lib/node_modules/hexo-cli/node_modules/bluebird/js/release/promise.js:649:10)
    at Promise._settlePromises (/home/noraj/.asdf/installs/nodejs/17.5.0/.npm/lib/node_modules/hexo-cli/node_modules/bluebird/js/release/promise.js:729:18)
    at _drainQueueStep (/home/noraj/.asdf/installs/nodejs/17.5.0/.npm/lib/node_modules/hexo-cli/node_modules/bluebird/js/release/async.js:93:12)
    at _drainQueue (/home/noraj/.asdf/installs/nodejs/17.5.0/.npm/lib/node_modules/hexo-cli/node_modules/bluebird/js/release/async.js:86:9)
    at Async._drainQueues (/home/noraj/.asdf/installs/nodejs/17.5.0/.npm/lib/node_modules/hexo-cli/node_modules/bluebird/js/release/async.js:102:5)
    at Immediate.Async.drainQueues [as _onImmediate] (/home/noraj/.asdf/installs/nodejs/17.5.0/.npm/lib/node_modules/hexo-cli/node_modules/bluebird/js/release/async.js:15:14) {
  reason: 'Specified list of YAML types (or a single Type object) contains a non-Type object.',
  mark: undefined
}

Environment & Settings

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

v17.5.0
8.4.1

Your site _config.yml (Optional)

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

# Site
title: title
subtitle: 'Documentation system'
description: 'static documentation site generator'
keywords:
  - documentation
  - markdown
  - custom
  - staticgen
author: John Doe
language: en
timezone: ''

# URL
## If your site is put in a subdirectory, set url as 'http://yoursite.com/child' and root as '/child/'
url: http://yoursite.com
root: /root/
permalink: :year/:month/:day/:title/
permalink_defaults:
pretty_urls:
  trailing_index: true # Set to false to remove trailing index.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: false
prismjs:
  enable: 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: 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
## Use post's date for updated date unless set in front-matter
updated_option: empty

# 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: hackdoc

# Deployment
## Docs: https://hexo.io/docs/deployment.html
deploy:
  type: ''

markdown:
  render:
    html: true
    xhtmlOut: false
    langPrefix: 'lang-'
    breaks: false
    linkify: true
    typographer: false
    quotes: '“”‘’'
  plugins:
  anchors:
    level: 2
    collisionSuffix: '-'
    permalink: true,
    permalinkClass: 'header-anchor'
    permalinkSide: 'right'
    permalinkSymbol: '#'
    case: 0
    separator: '-'

jsonContent:
  meta: false
  drafts: false
  file: content.json
  keywords: undefined
  dateFormat: undefined
  pages:
    title: true
    slug: true
    date: false
    updated: false
    comments: false
    path: true
    link: true
    permalink: true
    excerpt: false
    keywords: false
    text: true
    raw: false
    content: false
    author: false
  posts:
    title: true
    slug: true
    date: false
    updated: false
    comments: false
    path: true
    link: false
    permalink: true
    excerpt: false
    keywords: false
    text: true
    raw: false
    content: false
    author: false
    categories: true
    tags: true

Your theme _config.yml

Changing the theme to landscape still triggers the error so it's not from my theme.

# Bulmaswatch theme/skin variant/style
# see available values https://jenil.github.io/bulmaswatch/
bulmaswatch: default # cerulean, cosmo, cyborg, darkly, default, flatly, journal, litera, lumen, lux, materia, minty, nuclear, pulse, sandstone, simplex, slate, solar, spacelab, superhero, united, yeti

# Highlight.js style
# see available values https://highlightjs.org/static/demo/
hljs: atom-one-dark # a11y-dark, a11y-light, agate, androidstudio, an-old-hope, arduino-light, arta, ascetic, atelier-cave-dark, atelier-cave-light, atelier-dune-dark, atelier-dune-light, atelier-estuary-dark, atelier-estuary-light, atelier-forest-dark, atelier-forest-light, atelier-heath-dark, atelier-heath-light, atelier-lakeside-dark, atelier-lakeside-light, atelier-plateau-dark, atelier-plateau-light, atelier-savanna-dark, atelier-savanna-light, atelier-seaside-dark, atelier-seaside-light, atelier-sulphurpool-dark, atelier-sulphurpool-light, atom-one-dark, atom-one-dark-reasonable, atom-one-light, brown-paper, codepen-embed, color-brewer, darcula, dark, darkula, default, docco, dracula, far, foundation, github, github-gist, gml, googlecode, grayscale, gruvbox-dark, gruvbox-light, hopscotch, hybrid, idea, ir-black, isbl-editor-dark, isbl-editor-light, kimbie.dark, kimbie.light, lightfair, magula, mono-blue, monokai, monokai-sublime, night-owl, nord, obsidian, ocean, paraiso-dark, paraiso-light, pojoaque, purebasic, qtcreator_dark, qtcreator_light, railscasts, rainbow, routeros, school-book, shades-of-purple, solarized-dark, solarized-light, sunburst, tomorrow, tomorrow-night-blue, tomorrow-night-bright, tomorrow-night, tomorrow-night-eighties, vs2015, vs, xcode, xt256, zenburn

# Navbar at the top or the bottom
navbar:
  position: top # top, bottom
  title: true # display the title in navbar or not

toc: true # enable Table of Content (right bar)

logo:
  path: '/images/hackdoc_512.svg'
  navbar: true # display logo in the navbar (menu)
  sidebar: true # display logo in the sidebar

favicon:
  path: '/images/hackdoc_32.ico'

archive:
  style: 'both' # list, timeline, both

# Sass rendering options
node_sass:
  outputStyle: compressed
  precision: 5
  sourceComments: false

Hexo and Plugin version(npm ls --depth 0)

hexo-site@0.0.0 /home/noraj/Dev/hackdoc
├── hexo-description@0.1.0
├── hexo-excerpt-block@1.0.0
├── hexo-generator-archive@1.0.0
├── hexo-generator-category@1.0.0
├── hexo-generator-feed@3.0.0
├── hexo-generator-index@2.0.0
├── hexo-generator-json-content@4.2.3
├── hexo-generator-tag@1.0.0
├── hexo-multiauthor@0.0.1
├── hexo-render-pug@2.1.4
├── hexo-renderer-markdown-it@6.0.1
├── hexo-renderer-sass@0.4.0
├── hexo-server@3.0.0
├── hexo-spoiler@1.7.3
├── hexo-tag-admonition@1.2.0
├── hexo-tag-asciinema@0.0.3
├── hexo-tag-color-block@0.0.3
├── hexo-tag-kbd@0.0.1
├── hexo-tag-qrcode@1.0.0
└── hexo@6.1.0

Your package.json package.json

{
  "name": "hexo-site",
  "version": "0.0.0",
  "private": true,
  "scripts": {
    "build": "hexo generate",
    "clean": "hexo clean",
    "deploy": "hexo deploy",
    "server": "hexo server"
  },
  "hexo": {
    "version": "6.0.0"
  },
  "dependencies": {
    "hexo": "^6.1.0",
    "hexo-description": "^0.1.0",
    "hexo-excerpt-block": "^1.0.0",
    "hexo-generator-archive": "^1.0.0",
    "hexo-generator-category": "^1.0.0",
    "hexo-generator-feed": "^3.0.0",
    "hexo-generator-index": "^2.0.0",
    "hexo-generator-json-content": "^4.2.3",
    "hexo-generator-tag": "^1.0.0",
    "hexo-multiauthor": "^0.0.1",
    "hexo-render-pug": "^2.1.4",
    "hexo-renderer-markdown-it": "^6.0.1",
    "hexo-renderer-sass": "^0.4.0",
    "hexo-server": "^3.0.0",
    "hexo-spoiler": "^1.7.3",
    "hexo-tag-admonition": "^1.2.0",
    "hexo-tag-asciinema": "0.0.3",
    "hexo-tag-color-block": "0.0.3",
    "hexo-tag-kbd": "0.0.1",
    "hexo-tag-qrcode": "^1.0.0"
  }
}
dimaslanjaka commented 2 years ago

i have same problem too

noraj commented 2 years ago

@dimaslanjaka Have you a public repository with the error happening?

kkfive commented 2 years ago

i have same problem too. i change the package manager for PNPM solved the problem

lzkids commented 2 years ago

I also encountered this problem. Has it been solved?

dimaslanjaka commented 2 years ago

i solved this problem by installing version 6.0.0.

npm i hexo@6.0.0
MCSeekeri commented 2 years ago

@dimaslanjaka Have you a public repository with the error happening?

I have this problem too https://github.com/MCSeekeri/sciadv/runs/5655539928?check_suite_focus=true

noraj commented 2 years ago

I also encountered this problem. Has it been solved?

No @lzkids

i solved this problem by installing version 6.0.0.

I already have v6.0.0 as stated in package.json @dimaslanjaka

@MCSeekeri thanks for sharing the URL

dimaslanjaka commented 2 years ago

@dimaslanjaka Have you a public repository with the error happening?

I have this problem too https://github.com/MCSeekeri/sciadv/runs/5655539928?check_suite_focus=true

My fixed workflow https://github.com/dimaslanjaka/dimaslanjaka.github.io/actions

dimaslanjaka commented 2 years ago

fixed workflow https://github.com/dimaslanjaka/dimaslanjaka.github.io/runs/5657131614?check_suite_focus=true

noraj commented 2 years ago

replace hexo version 6.1.0 to 6.0.0 in package.json

Nice to know, thk for the workaround. It confirms 6.1.0 has introduced a bug and need to be fixed.

stevenjoezhang commented 2 years ago

Relevant pull request: https://github.com/hexojs/hexo/pull/4869

lzkids commented 2 years ago
  • install hexo 6.0.0
npm i hexo@6.0.0
* replace hexo version `6.1.0` to `6.0.0` in `package.json`
{
  "hexo": {
    "version": "6.0.0"
  }
}

if still get errors. delete package-lock.json and node_modules then reinstall with npm install hexo@6.0.0

fixed workflow https://github.com/dimaslanjaka/dimaslanjaka.github.io/runs/5657131614?check_suite_focus=true

thk

yoshinorin commented 2 years ago

@noraj @dimaslanjaka @kkfive @MCSeekeri @lzkids

How about below workaround?

// In your hexo project
// for hexo 6.1.0
$ npm install js-yaml@4.1.0

// for hexo 6.0.0
$ npm install js-yaml@4.0.0

I think this is probably effective. (I'm not sure this workaround has a bad side-effect or not. I think may be no bad side-effect... but not sure.)


P.S:

I have been able to reproduce this issue with https://github.com/hexojs/hexo-generator-category But, I think we need more time to fix this issue.

noraj commented 2 years ago

How about below workaround?

// In your hexo project
// for hexo 6.1.0
$ npm install js-yaml@4.1.0

It is already js-yaml 4.1.0 that is shipped with hexo 6.1.0

https://github.com/hexojs/hexo/blob/8d2102745fb804278238df4ba7832b871a78d899/package.json#L51

It's already what is in my package-lock.json. However I had to change this:

  "hexo": {
-    "version": "6.0.0"
+    "version": "6.1.0"
  },
  "dependencies": {
    "hexo": "^6.1.0",
yoshinorin commented 2 years ago

It is already js-yaml 4.1.0 that is shipped with hexo 6.1.0

Yes, I know. Not sure, but I assume this error seems incorrect version resolving of js-yaml.

How to reproduce?

// git clone & checkout
$ git clone https://github.com/hexojs/hexo-generator-category.git
$ git checkout -b issue-4917 f51949900e5dbd15902b45fe4399afb634d54b21
$ git log --oneline
  f519499 (HEAD -> issue-4917) chore(ci): migrate travisCI to GitHubActions (#70)
  f233a38 chore(deps): bump hexo-pagination from 1.0.0 to 2.0.0 (#46)
  fadee1a Upgrade to GitHub-native Dependabot (#45)

// hexo@5.4.0 will be installed
$ npm install

// install hexo@6.1.0
$ npm install hexo@6.1.0

// run test
$ npm run test

> hexo-generator-category@1.0.0 test
> mocha test/index.js

YAMLException: Specified list of YAML types (or a single Type object) contains a non-Type object.
    at /mnt/c/Users/username/development/hexo/hexo-generator-category/node_modules/hexo/node_modules/js-yaml/lib/schema.js:104:13
    at Array.forEach (<anonymous>)
    at Schema.extend (/mnt/c/Users/username/development/hexo/hexo-generator-category/node_modules/hexo/node_modules/js-yaml/lib/schema.js:102:12)
    at Object.<anonymous> (/mnt/c/Users/username/development/hexo/hexo-generator-category/node_modules/hexo/lib/plugins/renderer/yaml.js:5:36)
    at Module._compile (node:internal/modules/cjs/loader:1103:14)

Dependency tree

Here is the dependency tree after exec How to reproduce? section. Certainly, hexo@6.1.0 depends on js-yaml@4.1.0 and it seems no problem.

$ npm list js-yaml

hexo-generator-category@1.0.0 /mnt/c/Users/username/hexo/hexo-generator-category
├─┬ coveralls@3.1.1
│ └── js-yaml@3.14.1
├─┬ eslint@7.32.0
│ ├─┬ @eslint/eslintrc@0.4.3
│ │ └── js-yaml@3.14.1 deduped
│ └── js-yaml@3.14.1 deduped
├─┬ hexo@6.1.0
│ ├─┬ hexo-front-matter@3.0.0
│ │ └── js-yaml@4.1.0
│ └── js-yaml@4.1.0             <- should be use this. but not actually used???
├─┬ mocha@8.4.0
│ └── js-yaml@4.0.0
└─┬ nyc@15.1.0
  └─┬ @istanbuljs/load-nyc-config@1.1.0
    └── js-yaml@3.14.1 deduped

But, as you know exception occurs when run test. I wrote at the beginning of this comment, I'm not sure but it seems the require('js-yaml') resolves older than the 4.0.0 version of js-yaml..

I don't know which is the cause hexo, npm, or js-yaml.

Workaround

As I wrote in https://github.com/hexojs/hexo/issues/4917#issuecomment-1084567773. This exception will not occur after install js-yaml@4.1.0 manually. Because when you install a package manually npm use it preferentially.

$ npm install js-yaml@4.1.0
// for hexo 6.0.0
// $ npm install js-yaml@4.0.0

$ npm list js-yaml
hexo-generator-category@1.0.0 /mnt/c/Users/username/development/hexo/temp/hexo-generator-category
...
├─┬ hexo@6.1.0
│ ├─┬ hexo-front-matter@3.0.0
│ │ └── js-yaml@4.1.0 deduped
│ └── js-yaml@4.1.0 deduped
├── js-yaml@4.1.0               <- npm use this after install manually
...

$ npm run test

> hexo-generator-category@1.0.0 test
> mocha test/index.js

  Category generator
    ✓ pagination enabled
    ✓ pagination disabled
    ✓ custom pagination_dir

  3 passing (67ms)
dimaslanjaka commented 2 years ago

It is already js-yaml 4.1.0 that is shipped with hexo 6.1.0

Yes, I know. Not sure, but I assume this error seems incorrect version resolving of js-yaml.

How to reproduce?

// git clone & checkout
$ git clone https://github.com/hexojs/hexo-generator-category.git
$ git checkout -b issue-4917 f51949900e5dbd15902b45fe4399afb634d54b21
$ git log --oneline
  f519499 (HEAD -> issue-4917) chore(ci): migrate travisCI to GitHubActions (#70)
  f233a38 chore(deps): bump hexo-pagination from 1.0.0 to 2.0.0 (#46)
  fadee1a Upgrade to GitHub-native Dependabot (#45)

// hexo@5.4.0 will be installed
$ npm install

// install hexo@6.1.0
$ npm install hexo@6.1.0

// run test
$ npm run test

> hexo-generator-category@1.0.0 test
> mocha test/index.js

YAMLException: Specified list of YAML types (or a single Type object) contains a non-Type object.
    at /mnt/c/Users/username/development/hexo/hexo-generator-category/node_modules/hexo/node_modules/js-yaml/lib/schema.js:104:13
    at Array.forEach (<anonymous>)
    at Schema.extend (/mnt/c/Users/username/development/hexo/hexo-generator-category/node_modules/hexo/node_modules/js-yaml/lib/schema.js:102:12)
    at Object.<anonymous> (/mnt/c/Users/username/development/hexo/hexo-generator-category/node_modules/hexo/lib/plugins/renderer/yaml.js:5:36)
    at Module._compile (node:internal/modules/cjs/loader:1103:14)

Dependency tree

Here is the dependency tree after exec How to reproduce? section. Certainly, hexo@6.1.0 depends on js-yaml@4.1.0 and it seems no problem.

$ npm list js-yaml

hexo-generator-category@1.0.0 /mnt/c/Users/username/hexo/hexo-generator-category
├─┬ coveralls@3.1.1
│ └── js-yaml@3.14.1
├─┬ eslint@7.32.0
│ ├─┬ @eslint/eslintrc@0.4.3
│ │ └── js-yaml@3.14.1 deduped
│ └── js-yaml@3.14.1 deduped
├─┬ hexo@6.1.0
│ ├─┬ hexo-front-matter@3.0.0
│ │ └── js-yaml@4.1.0
│ └── js-yaml@4.1.0             <- should be use this. but not actually used???
├─┬ mocha@8.4.0
│ └── js-yaml@4.0.0
└─┬ nyc@15.1.0
  └─┬ @istanbuljs/load-nyc-config@1.1.0
    └── js-yaml@3.14.1 deduped

But, as you know exception occurs when run test. I wrote at the beginning of this comment, I'm not sure but it seems the require('js-yaml') resolves older than the 4.0.0 version of js-yaml..

I don't know which is the cause hexo, npm, or js-yaml.

Workaround

As I wrote in #4917 (comment). This exception will not occur after install js-yaml@4.1.0 manually. Because when you install a package manually npm use it preferentially.

$ npm install js-yaml@4.1.0
// for hexo 6.0.0
// $ npm install js-yaml@4.0.0

$ npm list js-yaml
hexo-generator-category@1.0.0 /mnt/c/Users/username/development/hexo/temp/hexo-generator-category
...
├─┬ hexo@6.1.0
│ ├─┬ hexo-front-matter@3.0.0
│ │ └── js-yaml@4.1.0 deduped
│ └── js-yaml@4.1.0 deduped
├── js-yaml@4.1.0               <- npm use this after install manually
...

$ npm run test

> hexo-generator-category@1.0.0 test
> mocha test/index.js

  Category generator
    ✓ pagination enabled
    ✓ pagination disabled
    ✓ custom pagination_dir

  3 passing (67ms)

latest of hexo-cli automated change local hexo package to version 6.0.0 so sad :( now, my website https://webmanajemen.com got truncated for many posts (i didnt check one by one of 800+ pages)

xtexChooser commented 2 years ago

I have the same situation after updating hexo to 6.1.0.

yoshinorin commented 2 years ago

We released hexo 6.2.0 just now. It includes this issue workaround.

https://github.com/hexojs/hexo/releases/tag/6.2.0

Thank you.

ghost commented 2 years ago

We released hexo 6.2.0 just now. It includes this issue workaround.

https://github.com/hexojs/hexo/releases/tag/6.2.0

Thank you.

i have same problem on 6.2.0

greenhandzdl commented 2 years ago

We released hexo 6.2.0 just now. It includes this issue workaround.

https://github.com/hexojs/hexo/releases/tag/6.2.0

Thank you.


PS D:\Users\20292\Documents\GitHub\hexo.bak> npm install hexo@latest -g

changed 93 packages in 4s

15 packages are looking for funding
  run `npm fund` for details
PS D:\Users\20292\Documents\GitHub\hexo.bak> hexo --safe
WARN  YAMLException: please see https://github.com/hexojs/hexo/issues/4917
FATAL TypeError: Cannot read property 'length' of undefined
    at composeNode (D:\Users\20292\Documents\GitHub\hexo.bak\node_modules\hexo\node_modules\js-yaml\lib\loader.js:1492:60)
    at readBlockMapping (D:\Users\20292\Documents\GitHub\hexo.bak\node_modules\hexo\node_modules\js-yaml\lib\loader.js:1104:12)
    at composeNode (D:\Users\20292\Documents\GitHub\hexo.bak\node_modules\hexo\node_modules\js-yaml\lib\loader.js:1441:12)
    at readDocument (D:\Users\20292\Documents\GitHub\hexo.bak\node_modules\hexo\node_modules\js-yaml\lib\loader.js:1625:3)
    at loadDocuments (D:\Users\20292\Documents\GitHub\hexo.bak\node_modules\hexo\node_modules\js-yaml\lib\loader.js:1688:5)
    at Object.load (D:\Users\20292\Documents\GitHub\hexo.bak\node_modules\hexo\node_modules\js-yaml\lib\loader.js:1714:19)
    at Hexo.yamlHelper (D:\Users\20292\Documents\GitHub\hexo.bak\node_modules\hexo\lib\plugins\renderer\yaml.js:20:15)
    at Hexo.tryCatcher (D:\Users\20292\Documents\GitHub\hexo.bak\node_modules\bluebird\js\release\util.js:16:23)
    at Hexo.<anonymous> (D:\Users\20292\Documents\GitHub\hexo.bak\node_modules\bluebird\js\release\method.js:15:34)
    at D:\Users\20292\Documents\GitHub\hexo.bak\node_modules\hexo\lib\hexo\render.js:81:22
    at tryCatcher (D:\Users\20292\Documents\GitHub\hexo.bak\node_modules\bluebird\js\release\util.js:16:23)
    at Promise._settlePromiseFromHandler (D:\Users\20292\Documents\GitHub\hexo.bak\node_modules\bluebird\js\release\promise.js:547:31)
    at Promise._settlePromise (D:\Users\20292\Documents\GitHub\hexo.bak\node_modules\bluebird\js\release\promise.js:604:18)
    at Promise._settlePromise0 (D:\Users\20292\Documents\GitHub\hexo.bak\node_modules\bluebird\js\release\promise.js:649:10)
    at Promise._settlePromises (D:\Users\20292\Documents\GitHub\hexo.bak\node_modules\bluebird\js\release\promise.js:729:18)
    at _drainQueueStep (D:\Users\20292\Documents\GitHub\hexo.bak\node_modules\bluebird\js\release\async.js:93:12)
    at _drainQueue (D:\Users\20292\Documents\GitHub\hexo.bak\node_modules\bluebird\js\release\async.js:86:9)
    at Async._drainQueues (D:\Users\20292\Documents\GitHub\hexo.bak\node_modules\bluebird\js\release\async.js:102:5)
    at Immediate.Async.drainQueues [as _onImmediate] (D:\Users\20292\Documents\GitHub\hexo.bak\node_modules\bluebird\js\release\async.js:15:14)
    at processImmediate (node:internal/timers:464:21)
leostudiooo commented 2 years ago

I tried yarn add js-yaml@latest, and it seems to solve the problem.

luchaoqi commented 2 years ago

Having the same problem on 6.2.0

leostudiooo commented 2 years ago

Having the same problem on 6.2.0

Have you tried this?

I tried yarn add js-yaml@latest, and it seems to solve the problem.

luchaoqi commented 2 years ago

Having the same problem on 6.2.0

Have you tried this?

I tried yarn add js-yaml@latest, and it seems to solve the problem.

Installed yarn and seems yarn add js-yaml@latest solves the problem :)

Jiangruoye commented 2 years ago

Why is version 6.2 still an error。but hexo gandhexo s http://localhost:4000/ is ok?

leostudiooo commented 2 years ago

I tried yarn add js-yaml@latest, and it seems to solve the problem.

Theoretically npm install js-yaml@latest may be ok as well.

Why is version 6.2 still an error。but hexo gandhexo s http://localhost:4000/ is ok?

Try the method above plz. Though I can't explain why it works. Maybe it's because hexo 6.2.0 requires the latest version of js-yaml but the module isn't the latest one, which triggers the problem.

Jiangruoye commented 2 years ago

I tried yarn add js-yaml@latest, and it seems to solve the problem.

Theoretically npm install js-yaml@latest may be ok as well.

Why is version 6.2 still an error。but hexo gandhexo s http://localhost:4000/ is ok?

Try the method above plz. Though I can't explain why it works. Maybe it's because hexo 6.2.0 requires the latest version of js-yaml but the module isn't the latest one, which triggers the problem.

Thank you for your answer But it still gets seven critical bug warnings, Later it was found that there was a problem with uploading one more folder for online use。

lorezyra commented 2 years ago

Latest version of HEXO 6.2.0 still fails to start. This workaround resolved it:

npm install js-yaml@4.1.0
RonaldJerez commented 2 years ago

I don't use hexo but had the same issue on my project. Landed here while trying to see if anyone was having the same issue and that it wasn't just me doing something stupid.

Did some digging and the problem is with the js-yaml-js-type dependency. If they move js-yaml as a peer dependency there it will ensure that the same instance/version is used and this error will go away. I opened a pull request to address it, hopefully it gets merged soon.

nodeca/js-yaml-js-types#5

EvanNotFound commented 2 years ago
  • install hexo 6.0.0
npm i hexo@6.0.0
  • replace hexo version 6.1.0 to 6.0.0 in package.json
{
  "hexo": {
    "version": "6.0.0"
  }
}

if still get errors. delete package-lock.json and node_modules then reinstall with npm install hexo@6.0.0

fixed workflow https://github.com/dimaslanjaka/dimaslanjaka.github.io/runs/5657131614?check_suite_focus=true

Thanks man, it works

jroliveira commented 2 years ago

Having the same problem on 6.3.0

Pil0tXia commented 2 years ago

I STILL have this problem after upgrading from 4.1.0 to 6.3.0, and npm install js-yaml@latest solved it.

leostudiooo commented 2 years ago

Added a PR to the docs' troubleshotting page regarding this issue.

kristofzerbe commented 1 year ago

Just my 50 cents...

All of these tips above only worked for me after deleting node_modules, package-lock.json, adding "js-yaml": "^4.1.0" to package.json and run npm install.

Now I got what I want ... fresh Hexo installation

Ezgx commented 1 year ago

image

Fgaoxing commented 1 year ago

我在使用Hexo 7.0.0 (RC1),遇到了该错误,确认配置文件格式正确,但是仍然报错

Fgaoxing commented 1 year ago

@kristofzerbe

unix2dos commented 6 months ago

hexo 7.2.0 same error

hexo -v WARN YAMLException: please see https://github.com/hexojs/hexo/issues/4917 hexo: 7.2.0