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 find module identifier-utils #252

Open
Bobini1 opened this issue Dec 19, 2024 · 8 comments
Open

[Bug]: Cannot find module identifier-utils #252

Bobini1 opened this issue Dec 19, 2024 · 8 comments
Labels
bug Something isn't working next Related to the next version

Comments

@Bobini1
Copy link

Bobini1 commented Dec 19, 2024

Describe the bug

On a project freshly set up with npx sv create app, running pnpm run storybook yields the following scary errors and fails!

> app@0.0.1 storybook
> 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:860:10)
    at defaultResolve (node:internal/modules/esm/resolve:984:11)
    at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:654:12)
    at #cachedDefaultResolve (node:internal/modules/esm/loader:603:25)
    at ModuleLoader.getModuleJobForRequire (node:internal/modules/esm/loader:353:53)
    at new ModuleJobSync (node:internal/modules/esm/module_job:341:34)
    at ModuleLoader.getModuleJobForRequire (node:internal/modules/esm/loader:413:11)
    at new ModuleJobSync (node:internal/modules/esm/module_job:341:34)
    at ModuleLoader.getModuleJobForRequire (node:internal/modules/esm/loader:413: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":"/home/bobini/app/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:860:10)
    at defaultResolve (node:internal/modules/esm/resolve:984:11)
    at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:654:12)
    at #cachedDefaultResolve (node:internal/modules/esm/loader:603:25)
    at ModuleLoader.getModuleJobForRequire (node:internal/modules/esm/loader:353:53)
    at new ModuleJobSync (node:internal/modules/esm/module_job:341:34)
    at ModuleLoader.getModuleJobForRequire (node:internal/modules/esm/loader:413:11)
    at new ModuleJobSync (node:internal/modules/esm/module_job:341:34)
    at ModuleLoader.getModuleJobForRequire (node:internal/modules/esm/loader:413:11)
✔ Would you like to help improve Storybook by sending anonymous crash reports? … yes

Reproduction link

https://github.com/Bobini1/broken-storybook-example

Reproduction steps

npx sv create app
Leave everything default except selecting storybook
cd app
npm run storybook

System

Storybook Environment Info:

  System:
    OS: Linux 6.12 Arch Linux
    CPU: (16) x64 AMD Ryzen 7 5800H with Radeon Graphics
    Shell: 5.9 - /usr/bin/zsh
  Binaries:
    Node: 23.4.0 - /usr/bin/node
    npm: 10.9.2 - /usr/bin/npm <----- active
    pnpm: 9.15.0 - /usr/bin/pnpm
  npmPackages:
    @storybook/addon-essentials: ^8.4.7 => 8.4.7 
    @storybook/addon-interactions: ^8.4.7 => 8.4.7 
    @storybook/addon-svelte-csf: ^5.0.0-next.21 => 5.0.0-next.21 
    @storybook/blocks: ^8.4.7 => 8.4.7 
    @storybook/svelte: ^8.4.7 => 8.4.7 
    @storybook/sveltekit: ^8.4.7 => 8.4.7 
    @storybook/test: ^8.4.7 => 8.4.7 
    storybook: ^8.4.7 => 8.4.7 

Additional context

It worked on Windows but I can't run it on Arch.

@Bobini1 Bobini1 added the bug Something isn't working label Dec 19, 2024
@Bobini1 Bobini1 changed the title [Bug]: Cannot find module identifiers-utils [Bug]: Cannot find module identifier-utils Dec 19, 2024
@Bobini1
Copy link
Author

Bobini1 commented Dec 20, 2024

Update: I reproduced it on Gentoo as well.

@shilman shilman transferred this issue from storybookjs/storybook Dec 22, 2024
@xeho91
Copy link
Collaborator

xeho91 commented Dec 22, 2024

Hi @Bobini1!

Could you confirm if changing Node.js version to v22 makes this scary error go away?

On both OS system, Windows and any of Linux distributions.

@xeho91 xeho91 added the next Related to the next version label Dec 22, 2024
@JReinhold
Copy link
Collaborator

JReinhold commented Dec 22, 2024

The problem is here, I probably missed this in my recent import conversion.

https://github.com/storybookjs/addon-svelte-csf/blob/next/src%2Fcompiler%2Fpre-transform%2Fcodemods%2Flegacy-story.ts#L12

We need to find a lint rule or tsconfig setting that stops this from happening, by ensuring that all imports have proper file extensions. We could experiment with "moduleResolution": "nodenext"

@xeho91
Copy link
Collaborator

xeho91 commented Dec 22, 2024

It's a little frustrating that the error has no mention of a missing file extension. 😞

In order to confirm, I've manually edited those imports inside the node_modules/ in the reproduction link provided. I found two places.

In the end, working with Node v23 is going to be blocked due to the last error:

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/.pnpm/@storybook+addon-svelte-csf@5.0.0-next.21_@storybook+svelte@8.4.7_storybook@8.4.7_svelte@5.15_l2uyyyw2pmvgj3flsyqrsufeme/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_PACKAGE_PATH_NOT_EXPORTED]: No "exports" main defined in ./node_modules/.pnpm/@storybook+addon-svelte-csf@5.0.0-next.21_@storybook+svelte@8.4.7_storybook@8.4.7_svelte@5.15_l2uyyyw2pmvgj3flsyqrsufeme/node_modules/@storybook/node-logger/package.json imported from ./node_modules/.pnpm/@storybook+addon-svelte-csf@5.0.0-next.21_@storybook+svelte@8.4.7_storybook@8.4.7_svelte@5.15_l2uyyyw2pmvgj3flsyqrsufeme/node_modules/@storybook/addon-svelte-csf/dist/compiler/post-transform/story/insert-description.js
    at exportsNotFound (node:internal/modules/esm/resolve:314:10)
    at packageExportsResolve (node:internal/modules/esm/resolve:604:13)
    at packageResolve (node:internal/modules/esm/resolve:774:12)
    at moduleResolve (node:internal/modules/esm/resolve:854:18)
    at defaultResolve (node:internal/modules/esm/resolve:984:11)
    at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:654:12)
    at #cachedDefaultResolve (node:internal/modules/esm/loader:603:25)
    at ModuleLoader.getModuleJobForRequire (node:internal/modules/esm/loader:353:53)
    at new ModuleJobSync (node:internal/modules/esm/module_job:341:34)
    at ModuleLoader.getModuleJobForRequire (node:internal/modules/esm/loader:413:11)

More info:

    at loadPreset (./node_modules/.pnpm/@storybook+core@8.4.7/node_modules/@storybook/core/dist/common/index.cjs:16477:13)

Which will be fixed once this one lands: storybookjs/storybook#30093

@JReinhold
Copy link
Collaborator

Ah forgot to merge that PR @xeho91, merged now, should go out in 8.5.0.

But it shouldn't be relevant since I removed the usage of @storybook/node-logger completely in #247
Perhaps you've tested with an older addon version?

@xeho91
Copy link
Collaborator

xeho91 commented Dec 22, 2024

It was client-logger that got removed 😅
https://github.com/storybookjs/addon-svelte-csf/releases/tag/v5.0.0-next.19

@seba9989
Copy link

This command NODE_OPTIONS=--no-experimental-require-module bun storybook allows you to bypass the error.

@eduardez
Copy link

This command NODE_OPTIONS=--no-experimental-require-module bun storybook allows you to bypass the error.

Had the same error and this worked for me, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working next Related to the next version
Projects
None yet
Development

No branches or pull requests

5 participants