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]: "ExternalDocs from @storybook/blocks fails with [Error reading preview.js]" #30724

Open
zinchenkoivan opened this issue Feb 28, 2025 · 1 comment

Comments

@zinchenkoivan
Copy link

Describe the bug

When using ExternalDocs from @storybook/blocks, it throws different errors depending on the environment:

In Next.js → Fails with:
Error reading preview.js

Image

In a React + Vite setup → Fails with:
document is not defined

Image

Current Setup:

  • Storybook version: 8.6.0
  • Next.js version: 15
  • React version: ^19.0.0

Previously Working Setup:

  • Storybook version: 7.6.3
  • Next.js version: 14
  • React version: 18

Reproduction link

https://codesandbox.io/p/github/zinchenkoivan/repro-bug-next/main?embed=1

Reproduction steps

  1. Run the project.
  2. Navigate to the file: src/app/page.tsx.

System

System:
    OS: macOS 15.3.1
    CPU: (10) arm64 Apple M1 Max
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 20.10.0 - ~/.nvm/versions/node/v20.10.0/bin/node
    Yarn: 1.22.21 - /opt/homebrew/bin/yarn
    npm: 10.2.3 - ~/.nvm/versions/node/v20.10.0/bin/npm <----- active
    pnpm: 9.1.2 - /opt/homebrew/bin/pnpm
  Browsers:
    Chrome: 133.0.6943.142
    Safari: 18.3
  npmPackages:
    @storybook/addon-essentials: ^8.6.2 => 8.6.2 
    @storybook/addon-onboarding: ^8.6.2 => 8.6.2 
    @storybook/blocks: ^8.6.2 => 8.6.2 
    @storybook/experimental-addon-test: ^8.6.2 => 8.6.2 
    @storybook/experimental-nextjs-vite: ^8.6.2 => 8.6.2 
    @storybook/react: ^8.6.2 => 8.6.2 
    @storybook/test: ^8.6.2 => 8.6.2 
    eslint-plugin-storybook: ^0.11.3 => 0.11.3 
    storybook: ^8.6.2 => 8.6.2

Additional context

Repository for reproduction (if needed): GitHub Repo.

@shilman
Copy link
Member

shilman commented Mar 5, 2025

First I want to point out that you're using an intentionally undocumented feature. Nevertheless, let's see what we can do. I suspect what's going on here is that there are two versions of React. @ndelangen can you comment here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants