storybook: [Bug]: Docs with react-vite doesn't work on 7.0.4 - Cannot read properties of undefined (reading 'fonts')
Describe the bug
Storybook render this error on docs page on a new storybook
Cannot read properties of undefined (reading ‘fonts’)
If I downgrade to 7.0.3, docs page working
To Reproduce
yarn dlx storybook@latest init --builder=vite --type=react yarn storybook
or yarn dlx storybook@next sandbox choose React Vite (TS) yarn install yarn storybook
System
Environment Info:
System:
OS: Linux 6.1 Manjaro Linux
CPU: (20) x64 12th Gen Intel(R) Core(TM) i7-12700H
Binaries:
Node: 19.8.1 - /tmp/xfs-72c84e66/node
Yarn: 3.2.0 - /tmp/xfs-72c84e66/yarn
npm: 8.19.2 - /usr/bin/npm
Browsers:
Firefox: 111.0.1
Additional context
The problem is only on 7.0.4
7.0.3 => OK 7.1.0-apha.3 => OK
About this issue
- Original URL
- State: open
- Created a year ago
- Reactions: 5
- Comments: 35 (5 by maintainers)
Still happening on a fresh project for me. Storybook is currently unusable with
react-vite
.I just got the same issue while updating from
v7.0.26
tov7.1.0
. What worked for me was to remove thenode_modules
folder, thepackage-lock.json
, and trigger again annpm install
. It seems that for some dependencies the right version was not picked up.Removing
node_modules
andpackage-lock.json
worked for me.For me I am using storybook
7.0.24
, don’t forget to runnpm i
after.@francesc79 worked for me!
in my case I needed to add
resolve: { dedupe: [ ... '@storybook/blocks', '@storybook/react', ],
viteConfig -> main.tsI had to remove node_modules and package-lock.json as well. Storybook 7.2.1 et react/vite/typescript here.
Faced this problem after upgrading to 7.2.0, removing both
node_modules
andpackage-lock.json
and redoing annpm i
resolved the issueI have the same error with 7.0.20. Is there any solution for that? I upgraded from 7.0.7 to 7.0.20.
We ran into that too @Th3S4mur41 . In our case, the fix was the following:
@storybook
andstorybook
into one PR (vs separate PRs)npm ls
oryarn list
). In our case, we were able to work around that by putting those transitive dependencies (or at least enough to trigger them all to update) as direct dependencies. For us, adding @storybook/api to our package.json directly was enough to cause everything to get updated on Dependabot PRs as it forced reevaluation of the etch team dependency.With those two, we haven’t run into this bug again.
This exact issue is also occurring for me with
7.0.26
– Docs work okay until I use<ColorPalette>
and then getting the undefined fonts error.That’s the workaround which worked for me.
I’m using the latest version now 7.6.5.
Have a nice day lol.
Using Dependabot groups as suggested by @broksonic21 solved the problem for us. We just had to add
@storybook/addons
and@storybook/theming
additionally to the mentioned@storybook/api
as direct dependency to make it work.Rmoving
node_modules
andpackage-lock.json
and runningnpm i
also solved the issue for me, unfortunately, 2 days later dependabot updated the following dependencies and the issue was back againSame workaround fixed the issue again, but it would be interesting to find the root cause
I also have this bug in 7.0.24. I even tested it using a brand new storybook project from scratch.
Its very easy to reproduce:
Put this in a story and it will crash
Not sure what can be done to fix this right now. I also tried the alpha version but could not get that one working either.
It may be coincidence but I started to experience this after upgrading to
7.0.11
. It’s funny (not actually 😢) because all my docs throw this error. Stories are fine.I was adding an icon doc and following the example pretty much to a tee.
The following will throw the font error…
But if I remove
IconGallery
and all it’s children the error goes away and I’m able to render the page. Granted it only has the title.My current setup:
For me this error occurs when importing a markdown file with a link or
<a>
into my.mdx
file.