Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Not generating new story files#30860

Unanswered
TheOnlyZac asked this question inHelp
Discussion options

Summary

I'm having some trouble setting up Storybook for the first time. The example stories were causing errors (something about duplicate keys), so I just deleted them. Then I created a basic component insrc/components/Button.tsx, ran Storybook, clicked "Create a new story" and selectedButton.tsx. This error appeared:

The new story file was successfully generated, but we are unable to index it. Please ensure that the new Story file is matched by the 'stories' glob pattern in your Storybook configuration.

It didn't actually generate any files; There's noButton.stories.tsx anywhere. Nothing is printed to the terminal. I'm using the default config files generated in.storybook, so I think it would be matched, if it exists.

"stories": ["../stories/**/*.mdx","../stories/**/*.stories.@(js|jsx|mjs|ts|tsx)"  ],

If it helps, I tried adding this to the list:

"../src/**/*.stories.@(js|jsx|mjs|ts|tsx)",

Then it does generate the story file insrc/components, but I get a different error (importers[path] is not a function). I would really like to keep them in a separate directory anyway. I'm working in Codespaces, and I tried it in a fresh container with the same results.

Additional information

.storybook/main.ts

importtype{StorybookConfig}from'@storybook/react-vite';import{join,dirname}from"path"/*** This function is used to resolve the absolute path of a package.* It is needed in projects that use Yarn PnP or are set up within a monorepo.*/functiongetAbsolutePath(value:string):any{returndirname(require.resolve(join(value,'package.json')))}constconfig:StorybookConfig={"stories":["../stories/**/*.mdx","../stories/**/*.stories.@(js|jsx|mjs|ts|tsx)",],"addons":[getAbsolutePath('@storybook/addon-essentials'),getAbsolutePath('@storybook/addon-onboarding'),getAbsolutePath('@chromatic-com/storybook'),getAbsolutePath("@storybook/experimental-addon-test")],"framework":{"name":getAbsolutePath('@storybook/react-vite'),"options":{}}};exportdefaultconfig;

Create a reproduction

Unable to reproduce in StackBlitz

You must be logged in to vote

Replies: 1 comment

Comment options

Ok, had a similar problem. I was trying to add a story for a component that was in./src/layout/MainLayout.tsx, but mymain.js didn't include that path! So after changingmain.js like this:

stories: [+   "../src/**/*.stories.@(js|jsx|mjs|ts|tsx)",    "../stories/**/*.mdx",    "../stories/**/*.stories.@(js|jsx|mjs|ts|tsx)",  ],

It started to work. Do note that you might encounter a different error which is discussedhere.

You must be logged in to vote
0 replies
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Category
Help
Labels
None yet
2 participants
@TheOnlyZac@fcFn

[8]ページ先頭

©2009-2025 Movatter.jp