storybookjs / storybook

Storybook is the industry standard workshop for building, documenting, and testing UI components in isolation
https://storybook.js.org
MIT License
84.58k stars 9.3k forks source link

[Bug]: Cannot find module react-dom/test-utils #29269

Open unional opened 1 month ago

unional commented 1 month ago

Describe the bug

When upgrading form storybook 8.2.6 to 8.3.4, I got this error.

It is caused by @storybook/react/dist/chunk-OOL6AVF7.mjs:

...
import * as DeprecatedReactTestUtils from 'react-dom/test-utils';

I'm using React 17.

Reproduction link

TBD

Reproduction steps

No response

System

Storybook Environment Info:

  System:
    OS: macOS 14.7
    CPU: (10) arm64 Apple M1 Pro
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 20.12.2 - ~/.nvm/versions/node/v20.12.2/bin/node
    npm: 10.5.0 - ~/.nvm/versions/node/v20.12.2/bin/npm <----- active
    pnpm: 9.8.0 - ~/.nvm/versions/node/v20.12.2/bin/pnpm
  Browsers:
    Chrome: 129.0.6668.71
    Safari: 18.0
  npmPackages:
    @storybook/addon-console: ^3.0.0 => 3.0.0 
    @storybook/addon-coverage: ^1.0.4 => 1.0.4 
    @storybook/addon-designs: ^8.0.3 => 8.0.3 
    @storybook/addon-essentials: ^8.3.4 => 8.3.4 
    @storybook/addon-interactions: ^8.3.4 => 8.3.4 
    @storybook/addon-links: ^8.3.4 => 8.3.4 
    @storybook/addon-storysource: ^8.3.4 => 8.3.4 
    @storybook/blocks: ^8.3.4 => 8.3.4 
    @storybook/manager-api: ^8.3.4 => 8.3.4 
    @storybook/react: ^8.3.4 => 8.3.4 
    @storybook/react-vite: ^8.3.4 => 8.3.4 
    @storybook/test: ^8.3.4 => 8.3.4 
    @storybook/test-runner: ^0.19.1 => 0.19.1 
    @storybook/theming: ^8.3.4 => 8.3.4 
    msw-storybook-addon: ^2.0.3 => 2.0.3 
    storybook: ^8.3.4 => 8.3.4 
    storybook-dark-mode: ^4.0.2 => 4.0.2

Additional context

No response

unional commented 1 month ago

Similar issue in @storybook/core:

// needs to be `react/jsx-runtime.js` in React 17
import { Fragment as b6, jsx as iu } from "react/jsx-runtime";
shilman commented 1 month ago

Do you a have a reproduction repo you can share? If not, can you create one? Go to https://storybook.new or see repro docs. Thank you! 🙏

unional commented 1 month ago

Not yet. This is mostly react 17 vs 18 issue. Some of storybook dependency (radux-ui, and storybook/core) is using react 18 specific stuff. So it just won't work with react 17 out of the box.

i.e. storybook 8.3 does not support react 17 anymore, unexpectedly.

I can work around it by patching those two packages locally.

unional commented 3 weeks ago

Update: a simple repro doesn't repro the issue. Maybe also related to tsconfig.

However, really not sure why not able to repro, as the import statement is pretty clear shouldn't work.

edoardo-bluframe commented 3 weeks ago

Same error here! yarn: 4.5.0, yarn workspaces mono and zero-installs

Just downgraded to 8.2.2 and everything works again!

Maybe let's look into this error?? 😄

github-actions[bot] commented 3 days ago

Hi there! Thank you for opening this issue, but it has been marked as stale because we need more information to move forward. Could you please provide us with the requested reproduction or additional information that could help us better understand the problem? We'd love to resolve this issue, but we can't do it without your help!