storybookjs / storybook

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

[Bug]: Could not find "./buttons.stories" for docs file #19763

Closed viveleroi closed 2 years ago

viveleroi commented 2 years ago

Describe the bug

Using storybook v7 alpha 47 with the vite builder. When attempting to run storybook I get the following error when trying to import a stories file. The file exists, it's in the same directory, so I can't find a cause on my end for this error.

Extraction error on app\components\buttons\buttons.docs.mdx: Error: Could not find "./buttons.stories" for docs file "app\components\buttons\buttons.docs.mdx

My file structure in components/buttons is:

buttons.docs.mdx
buttons.stories.tsx
buttons.tsx

In the mdx file, I am using this import per the 7 alpha migration docs: import * as ButtonStories from './buttons.stories';

I have also tried it with the .tsx file extension, produces the same error.

To Reproduce

This command breaks in git-bash, I'll have to try again in another terminal.

System

Environment Info:

  System:
    OS: Windows 10 10.0.22000
    CPU: (16) x64 11th Gen Intel(R) Core(TM) i7-11800H @ 2.30GHz
  Binaries:
    Node: 16.18.0 - C:\Program Files\nodejs\node.EXE
    Yarn: 3.2.4 - C:\Program Files\nodejs\yarn.CMD
    npm: 8.19.2 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Edge: Spartan (44.22000.120.0), Chromium (107.0.1418.35)


### Additional context

_No response_
shilman commented 2 years ago

Seems like a windows bug. @joshwooding Is this something you can look into?

viveleroi commented 2 years ago

Here is the full stack trace if it helps:

WSD-2DXW4M3: myproject-v3 (components) $ yarn run storybook
@storybook/cli v7.0.0-alpha.47

info => Loading presets
info => Loading presets
info => Loading presets
info => Starting manager..
WARN 🚨 Extraction error on app\components\buttons\buttons.docs.mdx: Error: Could not find "./buttons.stories" for docs file "app\components\buttons\buttons.docs.mdx".
C:\Users\mbotsko\Desktop\projects\myproject-v3\.yarn\__virtual__\@storybook-core-server-virtual-23951462ea\0\cache\@storybook-core-server-npm-7.0.0-alpha.47-4f2e47bbae-da8f15be91.zip\node_modules\@storybook\core-server\dist\cjs\utils\StoryIndexGenerator.js:314
        if (!ofTitle) throw new Error(`Could not find "${result.of}" for docs file "${relativePath}".`);
                            ^

Error: Could not find "./buttons.stories" for docs file "app\components\buttons\buttons.docs.mdx".
    at StoryIndexGenerator.extractDocs (C:\Users\mbotsko\Desktop\projects\myproject-v3\.yarn\__virtual__\@storybook-core-server-virtual-23951462ea\0\cache\@storybook-core-server-npm-7.0.0-alpha.47-4f2e47bbae-da8f15be91.zip\node_modules\@storybook\core-server\dist\cjs\utils\StoryIndexGenerator.js:314:29)
    at async C:\Users\mbotsko\Desktop\projects\myproject-v3\.yarn\__virtual__\@storybook-core-server-virtual-23951462ea\0\cache\@storybook-core-server-npm-7.0.0-alpha.47-4f2e47bbae-da8f15be91.zip\node_modules\@storybook\core-server\dist\cjs\utils\StoryIndexGenerator.js:123:31
    at async Promise.all (index 0)
    at async Promise.all (index 0)
    at async StoryIndexGenerator.updateExtracted (C:\Users\mbotsko\Desktop\projects\myproject-v3\.yarn\__virtual__\@storybook-core-server-virtual-23951462ea\0\cache\@storybook-core-server-npm-7.0.0-alpha.47-4f2e47bbae-da8f15be91.zip\node_modules\@storybook\core-server\dist\cjs\utils\StoryIndexGenerator.js:118:5)
    at async StoryIndexGenerator.ensureExtracted (C:\Users\mbotsko\Desktop\projects\myproject-v3\.yarn\__virtual__\@storybook-core-server-virtual-23951462ea\0\cache\@storybook-core-server-npm-7.0.0-alpha.47-4f2e47bbae-da8f15be91.zip\node_modules\@storybook\core-server\dist\cjs\utils\StoryIndexGenerator.js:144:7)
    at async StoryIndexGenerator.initialize (C:\Users\mbotsko\Desktop\projects\myproject-v3\.yarn\__virtual__\@storybook-core-server-virtual-23951462ea\0\cache\@storybook-core-server-npm-7.0.0-alpha.47-4f2e47bbae-da8f15be91.zip\node_modules\@storybook\core-server\dist\cjs\utils\StoryIndexGenerator.js:108:5)
joshwooding commented 2 years ago

Reproduced and have a fix :) Will raise a PR soon

shilman commented 2 years ago

Egads!! I just released https://github.com/storybookjs/storybook/releases/tag/v7.0.0-alpha.50 containing PR #19777 that references this issue. Upgrade today to the @next NPM tag to try it out!

npx sb upgrade --prerelease

Closing this issue. Please re-open if you think there's still more to do.