storybook: [Bug]: [7.0.0-beta.19]: using pnpm with nextjs, module not found: Error: Can't resolve 'style-loader'

Describe the bug

Running storybook by pnpm in a nextjs app throws the error “can’t resolve ‘style-loader’”.

To Reproduce

1. pnpm create next-app storybook.
2. cd ./storybook.
3. pnpm dlx storybook@next init --package-manager=pnpm.
4. pnpm run storybook.

The following error is thrown :
Module not found: Error: Can't resolve 'style-loader.

P.S : Works fine by yarn & npm.

System

System:
    OS: Windows 10 10.0.22621
    CPU: (8) x64 Intel(R) Core(TM) i5-8250U CPU @ 1.60GHz
  Binaries:
    Node: 16.19.0 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.19 - C:\Program Files\nodejs\yarn.CMD
    npm: 8.19.3 - C:\Program Files\nodejs\npm.CMD
    pnpm: 7.21.0
  Browsers:
    Edge: Spartan (44.22621.963.0), Chromium (108.0.1462.54)
  npmPackages:
    @storybook/addon-essentials: 7.0.0-beta.19 => 7.0.0-beta.19
    @storybook/addon-interactions: 7.0.0-beta.19 => 7.0.0-beta.19
    @storybook/addon-links: 7.0.0-beta.19 => 7.0.0-beta.19
    @storybook/blocks: 7.0.0-beta.19 => 7.0.0-beta.19
    @storybook/nextjs: 7.0.0-beta.19 => 7.0.0-beta.19
    @storybook/react: 7.0.0-beta.19 => 7.0.0-beta.19
    @storybook/testing-library: 0.0.13 => 0.0.13

Additional context

No response

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Reactions: 6
  • Comments: 16 (6 by maintainers)

Commits related to this issue

Most upvoted comments

Fixed by running pnpm -D css-loader style-loader postcss-loader

could --shamefully-hoist solve this?

It’s possible, but our goal is to avoid requiring that. We’ve done a lot of work already to clean things up so that we don’t rely on hoisting, looks like we just have a bit more to do here for next.js.

Adding a framework got me past the error, thanks @IanVS !