Skip to content

[Bug] Fails to load in Node 23 with SB_CORE-SERVER_0002 (CriticalPresetLoadError) #229

Closed
@JReinhold

Description

@JReinhold

Note

This issue has a temporary workaround

Describe the bug

When starting up a fresh Storybook project (both 8.3 and 8.4) with Svelte 5 and v5 of this addon, it fails to start with the error pasted below.

Downgrading Node to v22 fixes it. So does removing the addon and removing .svelte from the stories glob, which is why I've narrowed it down to this.

Steps to reproduce the behavior

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior

A clear and concise description of what you expected to happen.

Screenshots and/or logs

SB_CORE-SERVER_0002 (CriticalPresetLoadError): Storybook failed to load the following preset: ./.storybook/main.js.

Please check whether your setup is correct, the Storybook dependencies (and their peer dependencies) are installed correctly and there are no package version clashes.

If you believe this is a bug, please open an issue on Github.

SB_CORE-SERVER_0002 (CriticalPresetLoadError): Storybook failed to load the following preset: ./node_modules/@storybook/addon-svelte-csf/dist/preset.js.

Please check whether your setup is correct, the Storybook dependencies (and their peer dependencies) are installed correctly and there are no package version clashes.

If you believe this is a bug, please open an issue on Github.

Error [ERR_UNSUPPORTED_DIR_IMPORT]: Directory import './node_modules/@storybook/addon-svelte-csf/dist/compiler/post-transform/story' is not supported resolving ES modules imported from ./node_modules/@storybook/addon-svelte-csf/dist/compiler/post-transform/index.js
    at finalizeResolution (node:internal/modules/esm/resolve:263:11)
    at moduleResolve (node:internal/modules/esm/resolve:932:10)
    at defaultResolve (node:internal/modules/esm/resolve:1056:11)
    at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:650:12)
    at #cachedDefaultResolve (node:internal/modules/esm/loader:599:25)
    at ModuleLoader.getModuleJobForRequire (node:internal/modules/esm/loader:349:53)
    at new ModuleJobSync (node:internal/modules/esm/module_job:338:34)
    at ModuleLoader.getModuleJobForRequire (node:internal/modules/esm/loader:409:11)
    at new ModuleJobSync (node:internal/modules/esm/module_job:338:34)
    at ModuleLoader.getModuleJobForRequire (node:internal/modules/esm/loader:409:11)

More info:

    at loadPreset (./node_modules/@storybook/core/dist/common/index.cjs:139445:13)

More info:

    at loadPreset (./node_modules/@storybook/core/dist/common/index.cjs:139445:13)
    at async Promise.all (index 1)
    at async loadPresets (./node_modules/@storybook/core/dist/common/index.cjs:139455:55)
    at async getPresets (./node_modules/@storybook/core/dist/common/index.cjs:139488:11)
    at async buildDevStandalone (./node_modules/@storybook/core/dist/core-server/index.cjs:48473:11)
    at async withTelemetry (./node_modules/@storybook/core/dist/core-server/index.cjs:47080:12)
    at async dev (./node_modules/@storybook/core/dist/cli/bin/index.cjs:2877:3)
    at async r.<anonymous> (./node_modules/@storybook/core/dist/cli/bin/index.cjs:2929:74)

WARN Broken build, fix the error above.
WARN You may need to refresh the browser.

WARN   Failed to load preset: {"type":"presets","name":"/Users/jeppe/dev/temp/sv2/node_modules/@storybook/addon-svelte-csf/dist/preset.js"} on level 1
Error [ERR_UNSUPPORTED_DIR_IMPORT]: Directory import './node_modules/@storybook/addon-svelte-csf/dist/compiler/post-transform/story' is not supported resolving ES modules imported from ./node_modules/@storybook/addon-svelte-csf/dist/compiler/post-transform/index.js
    at finalizeResolution (node:internal/modules/esm/resolve:263:11)
    at moduleResolve (node:internal/modules/esm/resolve:932:10)
    at defaultResolve (node:internal/modules/esm/resolve:1056:11)
    at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:650:12)
    at #cachedDefaultResolve (node:internal/modules/esm/loader:599:25)
    at ModuleLoader.getModuleJobForRequire (node:internal/modules/esm/loader:349:53)
    at new ModuleJobSync (node:internal/modules/esm/module_job:338:34)
    at ModuleLoader.getModuleJobForRequire (node:internal/modules/esm/loader:409:11)
    at new ModuleJobSync (node:internal/modules/esm/module_job:338:34)
    at ModuleLoader.getModuleJobForRequire (node:internal/modules/esm/loader:409:11)
(node:51681) ExperimentalWarning: CommonJS module /Users/jeppe/dev/temp/sv2/node_modules/@storybook/core/dist/common/index.cjs is loading ES Module /Users/jeppe/dev/temp/sv2/node_modules/@storybook/addon-svelte-csf/dist/preset.js using require().
Support for loading ES Module in require() is an experimental feature and might change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
(node:51681) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.

Environment

Storybook Environment Info:

  System:
    OS: macOS 13.1
    CPU: (10) arm64 Apple M1 Pro
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    **Node: 23.1.0** - ~/Library/Caches/fnm_multishells/45040_1731443426590/bin/node
    npm: 10.9.0 - ~/Library/Caches/fnm_multishells/45040_1731443426590/bin/npm <----- active
    pnpm: 9.12.0 - ~/Library/Caches/fnm_multishells/45040_1731443426590/bin/pnpm
  Browsers:
    Chrome: 130.0.6723.117
    Edge: 130.0.2849.80
    Safari: 16.2
  npmPackages:
    @storybook/addon-essentials: 8.3.6 => 8.3.6
    @storybook/addon-interactions: 8.3.6 => 8.3.6
    @storybook/addon-links: 8.3.6 => 8.3.6
    @storybook/addon-svelte-csf: ^5.0.0-next.11 => 5.0.0-next.11
    @storybook/blocks: 8.3.6 => 8.3.6
    @storybook/svelte: 8.3.6 => 8.3.6
    @storybook/sveltekit: 8.3.6 => 8.3.6
    @storybook/test: 8.3.6 => 8.3.6
    storybook: 8.3.6 => 8.3.6

Additional Context

Originally reported in sveltejs/cli#296 (comment) and sveltejs/cli#295

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinghas workaroundThis issue has a possible workaroundnextRelated to the next version

    Type

    No type

    Projects

    • Status

      Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions