storybook: 5.0.0-rc.1 typography of undefined, empty theme object
Describe the bug Getting an empty screen with the following error:
TypeError: typography is undefined
Whole stack can be seen in screenshot.
I suspect that the theme object has been passed on by the theme provider. I’m not using any addons.
Expected behavior Not to crash?
Screenshots

System:
- Framework: react 16.8.2
- Version: 5.0.0-rc.1
Additional context:
It used to work with v5.0.0-alpha.1
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 2
- Comments: 25 (13 by maintainers)
Commits related to this issue
- ADD webpack aliases for storybook packages, enforcing singleton modules Fixing https://github.com/storybooks/storybook/issues/5663 — committed to storybookjs/storybook by ndelangen 5 years ago
- resolve paths locally if possible https://github.com/storybooks/storybook/issues/5663 — committed to storybookjs/storybook by ndelangen 5 years ago
I received this error as well despite using the exact same Storybook 5 config on another project without issues.
Turns out it was a module resolution issue with a different package
I installed
emotion-theming@10as a devDependency and it fixed it right upI’m still getting this error with
5.0.1-I even ran
npx -p @storybook/cli sb init --forceto try to start fresh in our repo and and am still receiving this error. I also had to manually add@storybook/themingbecause it was throwing a module not found error with@emotion/core/package.json. We are using emotion@9 in our core product, otherwise not sure what the issue can be. This is in the https://github.com/getsentry/sentry repo.I am also receiving this error. In my own dependencies I have
emotion-theming@9.x.x, but I can see the@storybook/themingrequires version10.x.x.Possibly it’s something to do with that.
I think this is related to #5532. For me it was caused by multiple
@storybook/themingpackage. Because I work with a monorepo yarn hoisted some@storybookpackage but it also added some in the package’s directory. I’ve added nohoist option to the root package.json like this:Thanks for the reply.
The setup has no custom config and no themes. I even commented out loading of stories. I wasn’t entirely sure whether you need
@storybook/theming. I did both with and without@storybook/themingseem to have made no difference.Edit: The stacktrace lead to this particular line: https://github.com/storybooks/storybook/blob/5158d13ff2af306b315c02a7d1325ef59562d230/lib/theming/src/global.ts#L14
Hi, to anyone still looking at this issue, I ran into it as well. My issues were with my
typescriptversion not being the same as storybook’s, as well as a component library running an older version ofstorybookwithemotion.To fix it, I changed my version (
3.5.1) of typescript to3.4.1and it seemed to do the trick.Also, In my case I have to reference the individual components of a library instead of the components exported from its build. These components relied on
emotion@9.2.9as well asreact-emotionand also caused this bug. Fortunately for me, the lib only made use of styled fromreact-emotion. So I just added an alias in my webpack build for storybook to pass any ref ofreact-emotionto@emotion/styled:'react-emotion': path.join(__dirname, "..", "node_modules", "@emotion", "styled")I also used @B3zo0 's suggestion about nohoist to keep that library’s use of storybook at bay.
Hope this helps someone!
Sorry If I’m unclear about what I’m doing. This is only like my second or third GitHub post ever!
Super excited to upgrade to to storybook@5. @ndelangen, sorry I totally forgot to get around to reviewing the code, the last week just swamped me badly.
@shilman I also just ran into this issue. My issue is that because I have emotion-theming@9.x in my package, the ThemeProvider included is from this version (node_modules/emotion-theming) as opposed to node_modules/@storybook/theming/node_modules/emotion-theming. I suspect this has to do with the storybook dll (a webpack dll) that links all imports from emotion-theming to the root node_modules directory. This is just a suspicion though since i haven’t traced it 100%. All i know is the theming module (node_modules/@storybook/theming/node_modules/emotion-theming) is never loaded.
Thanks @denkristoffer. Starting the 5.1 release process now so probably won’t bother tracking it down for 5.0 unless it takes too long to release 5.1 and there’s an easy fix to backport.
@shilman Sorry for the delay, i tried it today and it works!
Thank you, much appreciated 😃