Skip to content

jsdom 27 produces error ERR_REQUIRE_ESM #9281

@manuel-mauky

Description

@manuel-mauky

Describe the bug

We're running [email protected] with [email protected] without issues.
However, now we wanted to update jsdom to 27.3.0 and there seems to be an issue with this combination.
When running the test, we get this error message:

Error: require() of ES Module /Users/<path-to-project>/node_modules/.pnpm/[email protected]/node_modules/parse5/dist/index.js from 
/Users/<path-to-project>/node_modules/.pnpm/[email protected]/node_modules/jsdom/lib/jsdom/browser/parser/html.js not supported.

Instead change the require of index.js in 
/Users/<path-to-project>/node_modules/.pnpm/[email protected]/node_modules/jsdom/lib/jsdom/browser/parser/html.js
to a dynamic import() which is available in all CommonJS modules.

I'm not sure if the issue is in jsdom or vitest.

Reproduction

https://github.com/manuel-mauky/repro_vitest_jsdom

Commit 6bc8a7d adds jsdom@26 and everything works fine.
Commit ff82006 updates jsdom to 27 and now the tests are failing.

I also created a stackblitz which also fails with jsdom@27, but with a different error message: https://stackblitz.com/edit/vitest-dev-vitest-vqsv97sz?file=package.json

I've posted this stackblitz also in #9279 where it was mentioned that it might be an incompatibility of jsdom and stackblitz itself.

System Info

System:
    OS: macOS 26.1
    CPU: (10) arm64 Apple M1 Pro
    Memory: 73.77 MB / 32.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 20.11.1 - /Users/<username>/.local/state/fnm_multishells/63026_1765968683731/bin/node
    npm: 10.2.4 - /Users/<username>/.local/state/fnm_multishells/63026_1765968683731/bin/npm
    pnpm: 9.6.0 - /Users/<username>/.local/state/fnm_multishells/63026_1765968683731/bin/pnpm
    Deno: 2.5.4 - /opt/homebrew/bin/deno
  Browsers:
    Chrome: 143.0.7499.110
    Edge: 143.0.3650.80
    Firefox: 145.0.2
    Safari: 26.1
  npmPackages:
    @vitejs/plugin-react: 5.1.2 => 5.1.2
    @vitest/spy: 4.0.16 => 4.0.16
    vitest: 4.0.16 => 4.0.16

Used Package Manager

pnpm

Validations

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions