Skip to content

[Bug]: Compatibility issues with Node 22.18 or higher #320

@yannbf

Description

@yannbf

Version

❯ npx storybook@latest info

Storybook Environment Info:

  System:
    OS: macOS 15.6
    CPU: (14) arm64 Apple M4 Pro
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 22.18.0 - ~/.volta/tools/image/node/22.18.0/bin/node
    Yarn: 1.22.22 - ~/.volta/tools/image/yarn/1.22.22/bin/yarn <----- active
    npm: 10.9.3 - ~/.volta/tools/image/node/22.18.0/bin/npm
    pnpm: 10.14.0 - ~/.volta/bin/pnpm
  Browsers:
    Chrome: 139.0.7258.67
    Safari: 18.6
  npmPackages:
    @storybook/addon-a11y: ^9.0.18 => 9.1.1
    @storybook/addon-docs: ^9.0.18 => 9.1.1
    eslint-plugin-storybook: ^9.0.18 => 9.1.1
    storybook: ^9.0.18 => 9.1.1
    storybook-react-rsbuild: ^2.0.2 => 2.0.3

Details

Hey there, I'm forwarding an issue that was opened in the Storybook repo, which upon investigation, turns out it's related to the rsbuild package (it crashes on rsbuild and but works as intented when converting the project from rsbuild to Webpack5).

Seems like this is the culprit:

node_modules/storybook-builder-rsbuild/node_modules/find-cache-dir/index.js

Would you mind taking a look?

Here is the original issue: storybookjs/storybook#32223

And the original description:

The current storybook 9.1 release doesn't successfully build with nodejs 22.18.0. This seems to be an NodeJs issue, as it was not a problem in node 22.17.1.
Unfortunately, I believe it is related to the intentional ESM loader changes made in nodejs/node#58598 so storybook may need a workaround.

Or maybe that's totally off base and it has something to do with the recently stabilized type stripping. I find that unlikely though since this was also enabled in node 20.19.4 and it works fine.

In the reproduction link below I don't have my actual config since it wouldn't work to reproduce this. This is because I can't control the version of node used in stackblitz (that I know of, I haven't used it before). If there is a way to do this I'm happy to copy my actual config to a stackblitz setup, and setup the proper node version.

Reproduce link

https://stackblitz.com/edit/github-mnnc5n4h?file=package.json

Reproduce Steps

  1. Install nodejs 22.18.0
  2. run your storybook build script e.g. yarn storybook or yarn build:storybook
    2.1. You can use any package manager. I confirmed the same behavior w/ pnpm 10.
  3. Observe there is an exception with the following message
❯ yarn build:storybook
yarn run v1.22.22
$ storybook build
storybook v9.1.1

info => Cleaning outputDir: storybook-static
info => Loading presets
TypeError: Cannot read properties of undefined (reading 'getStatus')
    at ModuleLoader.getModuleJobForRequire (node:internal/modules/esm/loader:463:22)
    at new ModuleJobSync (node:internal/modules/esm/module_job:393:34)
    at ModuleLoader.importSyncForRequire (node:internal/modules/esm/loader:426:11)
    at loadESMFromCJS (node:internal/modules/cjs/loader:1519:24)
    at Module._compile (node:internal/modules/cjs/loader:1670:5)
    at node:internal/modules/cjs/loader:1820:10
    at Object.newLoader (./node_modules/esbuild-register/dist/node.js:2262:9)
    at extensions..js (./node_modules/esbuild-register/dist/node.js:4833:24)
    at Module.load (node:internal/modules/cjs/loader:1423:32)
    at Function._load (node:internal/modules/cjs/loader:1246:12)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

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