chore(web): Upgrade Node.js minimum version to 22.12.0 for jsdom 27 compatibility #21556

Closed
opened 2026-02-21 20:13:11 -05:00 by yindo · 0 comments
Owner

Originally created by @lyzno1 on GitHub (Jan 10, 2026).

Summary

The current Node.js version requirement (>=22.11.0) is incompatible with jsdom 27.3.0, causing test failures with ERR_REQUIRE_ESM errors.

Problem

When running pnpm test locally with Node.js 22.11.0:

Error: require() of ES Module .../parse5@8.0.0/.../index.js 
from .../jsdom@27.3.0/.../html.js not supported.

Root Cause Analysis

  1. jsdom 27.3.0 is CommonJS ("type": "commonjs") but depends on parse5 8.0.0 which is pure ESM ("type": "module")
  2. jsdom internally uses require("parse5") which fails in Node.js < 22.12.0
  3. Node.js 22.12.0 introduced require(esm) enabled by default, allowing CommonJS to require ES modules
  4. jsdom's engines field explicitly requires: "node": "^20.19.0 || ^22.12.0 || >=24.0.0"

Version Gap

Component Current Required
Node.js 22.11.0 22.12.0+
jsdom 27.3.0
parse5 8.0.0

Proposed Changes

  1. Update /.nvmrc: 22.11.022.20.0 (lts-latest)
  2. Update /web/package.json engines: >=v22.11.0>=22.12.0

Why 22.20.0 for .nvmrc?

  • 22.20.0 is the current LTS latest version
  • 22.12.0 is the minimum required for jsdom compatibility
  • Using LTS latest ensures developers get security patches and bug fixes
  • package.json engines uses >=22.12.0 for flexibility

References

Impact

  • CI/CD: No change needed (node-version: 22 already uses latest 22.x)
  • ⚠️ Local development: Developers need to upgrade Node.js to 22.12.0+

Test Plan

  • pnpm test passes locally with Node.js 22.20.0
  • CI tests pass
  • All existing functionality works as expected
Originally created by @lyzno1 on GitHub (Jan 10, 2026). ## Summary The current Node.js version requirement (`>=22.11.0`) is incompatible with jsdom 27.3.0, causing test failures with `ERR_REQUIRE_ESM` errors. ## Problem When running `pnpm test` locally with Node.js 22.11.0: ``` Error: require() of ES Module .../parse5@8.0.0/.../index.js from .../jsdom@27.3.0/.../html.js not supported. ``` ### Root Cause Analysis 1. **jsdom 27.3.0** is CommonJS (`"type": "commonjs"`) but depends on **parse5 8.0.0** which is pure ESM (`"type": "module"`) 2. jsdom internally uses `require("parse5")` which fails in Node.js < 22.12.0 3. **Node.js 22.12.0** introduced `require(esm)` enabled by default, allowing CommonJS to require ES modules 4. jsdom's `engines` field explicitly requires: `"node": "^20.19.0 || ^22.12.0 || >=24.0.0"` ### Version Gap | Component | Current | Required | |-----------|---------|----------| | Node.js | 22.11.0 | **22.12.0+** | | jsdom | 27.3.0 | ✅ | | parse5 | 8.0.0 | ✅ | ## Proposed Changes 1. Update `/.nvmrc`: `22.11.0` → `22.20.0` (lts-latest) 2. Update `/web/package.json` engines: `>=v22.11.0` → `>=22.12.0` ## Why 22.20.0 for .nvmrc? - **22.20.0** is the current LTS latest version - **22.12.0** is the minimum required for jsdom compatibility - Using LTS latest ensures developers get security patches and bug fixes - `package.json` engines uses `>=22.12.0` for flexibility ## References - [vitest-dev/vitest#9281](https://github.com/vitest-dev/vitest/issues/9281) - jsdom 27 produces error ERR_REQUIRE_ESM - [jsdom/jsdom#4000](https://github.com/jsdom/jsdom/issues/4000) - Crashing with ERR_REQUIRE_ESM - [Node.js 22.12.0 Release Notes](https://nodejs.org/en/blog/release/v22.12.0) - require(esm) enabled by default ## Impact - ✅ CI/CD: No change needed (`node-version: 22` already uses latest 22.x) - ⚠️ Local development: Developers need to upgrade Node.js to 22.12.0+ ## Test Plan - [ ] `pnpm test` passes locally with Node.js 22.20.0 - [ ] CI tests pass - [ ] All existing functionality works as expected
yindo closed this issue 2026-02-21 20:13:11 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#21556