Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] Cannot run Storybook in a completely blank Svelte project #258

Open
jchillerup opened this issue Jan 3, 2025 · 2 comments
Open

[Bug] Cannot run Storybook in a completely blank Svelte project #258

jchillerup opened this issue Jan 3, 2025 · 2 comments
Labels
bug Something isn't working duplicate This issue or pull request already exists

Comments

@jchillerup
Copy link

Describe the bug

I toyed around with Svelte in the previous iteration. Wanted to start a new project with Svelte 5 and found out that SvelteKit and the sv tool is the new thing. So I did.

Went through the little wizard and set up my project with Storybook, among other things. Looks like it installs fine (albeit with a few warnings that may be related to Homebrew-governed modules vs. project-specific modules?)

(node:17328) ExperimentalWarning: CommonJS module /opt/homebrew/lib/node_modules/npm/node_modules/debug/src/node.js is loading ES Module /opt/homebrew/lib/node_modules/npm/node_modules/supports-color/index.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:17366) ExperimentalWarning: CommonJS module /opt/homebrew/lib/node_modules/npm/node_modules/debug/src/node.js is loading ES Module /opt/homebrew/lib/node_modules/npm/node_modules/supports-color/index.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)

Either way, I get the "Storybook was successfully installed in your project! 🎉" message, so I proceed to run yarn run storybook which yields this error:

$ yarn run storybook
yarn run v1.22.19
$ storybook dev -p 6006
@storybook/core v8.4.7

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_MODULE_NOT_FOUND]: Cannot find module './node_modules/@storybook/addon-svelte-csf/dist/utils/identifier-utils' imported from ./node_modules/@storybook/addon-svelte-csf/dist/compiler/pre-transform/codemods/legacy-story.js
    at finalizeResolution (node:internal/modules/esm/resolve:275: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:16477:13)

More info:

    at loadPreset (./node_modules/@storybook/core/dist/common/index.cjs:16477:13)
    at async Promise.all (index 1)
    at async loadPresets (./node_modules/@storybook/core/dist/common/index.cjs:16487:55)
    at async getPresets (./node_modules/@storybook/core/dist/common/index.cjs:16520:11)
    at async buildDevStandalone (./node_modules/@storybook/core/dist/core-server/index.cjs:37145:11)
    at async withTelemetry (./node_modules/@storybook/core/dist/core-server/index.cjs:35757:12)
    at async dev (./node_modules/@storybook/core/dist/cli/bin/index.cjs:2591:3)
    at async s.<anonymous> (./node_modules/@storybook/core/dist/cli/bin/index.cjs:2643: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/jc/code/kartoffel/kartoffel/node_modules/@storybook/addon-svelte-csf/dist/preset.js"} on level 1
Error [ERR_MODULE_NOT_FOUND]: Cannot find module './node_modules/@storybook/addon-svelte-csf/dist/utils/identifier-utils' imported from ./node_modules/@storybook/addon-svelte-csf/dist/compiler/pre-transform/codemods/legacy-story.js
    at finalizeResolution (node:internal/modules/esm/resolve:275: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:22888) ExperimentalWarning: CommonJS module /Users/jc/code/kartoffel/kartoffel/node_modules/@storybook/core/dist/common/index.cjs is loading ES Module /Users/jc/code/kartoffel/kartoffel/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)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Steps to reproduce the behavior

  1. npx sv create kartoffel
  2. Fill out the wizard (I tried both Typescript and JS, and both yarn and npm as package managers)
  3. yarn run storybook / npm run storybook
  4. Look at that error

Expected behavior

I had expected the script to give me an URL to open the Storybook application.

Screenshots and/or logs

N/A

Environment

  • OS: Mac OS Sonoma 14.3.1
  • Node.js version: v23.1.0 (Homebrew)
  • NPM version: 10.9.0
  • Device (if applicable): MacBook Pro M2

Additional context

Thanks for taking the time to read my bug report :)

@jchillerup jchillerup added the bug Something isn't working label Jan 3, 2025
@jchillerup
Copy link
Author

I wasn't able to reproduce this in a Ubuntu Docker container, so it probably has something to do with my environment.

@xeho91 xeho91 added the duplicate This issue or pull request already exists label Jan 3, 2025
@xeho91
Copy link
Collaborator

xeho91 commented Jan 3, 2025

This is a duplicate of #229.
There's a workaround.

As for your Ubuntu Docker container, I'm guessing it has a different Node.js version than v23.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

2 participants