addon-svelte-csf: [Bug] Fails to load in Node 23 with `SB_CORE-SERVER_0002 (CriticalPresetLoadError)`
[!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
- Go to ‘…’
- Click on ‘…’
- Scroll down to ‘…’
- 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 https://github.com/sveltejs/cli/issues/296#issuecomment-2471519367 and https://github.com/sveltejs/cli/issues/295
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 6
- Comments: 20 (4 by maintainers)
fyi i got an
[ERR_UNSUPPORTED_DIR_IMPORT]error running storybook + svelte 5 with node 22.12.0 that went away after downgrading to 20.18Having the same issue:
Node version: v22.12.0 Already tried with beta and non beta version of storybook
Hm, so from the initial investigation.
I’ve been manually fixing the
[ERR_UNSUPPORTED_DIR_IMPORT]errors insidenode_modules/. Then I ended up with different errors. The last one that blocked me from continuing is:While everything seems to be OK inside the
package.jsonexports inside@storybook/node-logger. 🤷EDIT. I was able to continue the
@storybook/node-loggerissue by changing:There either has been some breaking change in Node.js that I am not aware of, or something else is causing all those different errors.
EDIT. I got it working for Node.js
v23. I’ve replaced every relative imports paths to usepackage.json#imports. I’m not yet sure yet how to conclude this issue. Is the Node.js own feature a problem? Should we just stop usingpackage.json#imports(I haven’t tested if removing them completely works)? Or you can’t use both relative andpackage.json#importsat same time?EDIT. The above solution breaks in Node.js
v22😐 with different error:And to fix this one, I had to revert the change in
package.json#exportsinside@storybook/node-logger.I didn’t want to go to 5 since its prerelease so yes I was hoping it would end up in a released 4.2.1 version that I could update to. I didn’t expect it to be in 4.2 tho. I didn’t know how long your canary / test cycles were and when I could potentially expect to update to 4.2.1. Thanks!
This should be fixed by https://github.com/storybookjs/addon-svelte-csf/pull/260 in
v5.0.0-next.22of the addon, let me know if the issue persists for any of you!We’re aware that this is a serious issue and will try to fix it ASAP ⏳
Ah yes
NODE_OPTIONS="--no-experimental-require-module" npm run storybookworks! FTWFWIIW I am using Git for Windows bash shell.