storybook: 5.0.0-rc4 - cannot read property 'secondary' of undefined
Describe the bug
In 5.0.0-rc4, the storybook UI fails to load, throwing cannot read property 'secondary' of undefined, while trying to read theme.color.secondary in node_modules/@storybook/ui/dist/components/layout/draggers.js. The provided theme object is empty.
I’m seeing this even if I wipe out my custom webpack config and use the default storybook config, with no addons.
If I downgrade to rc3, the problem goes away.
Screenshots
System:
- OS: MacOS 10.14.1
- Device: Macbook Pro 2016
- Browser: chrome & safari
- Framework: react
- Addons: None
- Version: Storybook 5.0.0-rc4 (but not 5.0.0-rc3), with React 16.8.1
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 5
- Comments: 46 (26 by maintainers)
Ahh, gotcha. FWIW, I can work around the issue by adding an explicit dependency for
@storybook/themingin my package.jsonFor anyone running into the
EntryModuleNotFoundError(I landed here while Googling / troubleshooting) I want to point out that it sounds like this is specific to yarn and that @jdelStrother’s recommendation fixed it for me:📝 I’m also not using any custom theming. I did try blowing away
node_modulesand evenyarn.lock. Still had the same issue with5.0.0.yarn add -D @storybook/themingdid the trick.FWIW here is my entire diff (minus lock file) for upgrading a project from
4.x->5.0.0just now. Thank you to all who were involved in this effort! Seriously great work 😃Ran into the same issue.
I can confirm that deleting
yarn.lockand adding@storybook/themingwith a fresh install ofnode_modulesworked to solve this.Thanks for the help @shilman and bringing up the issue @jdelStrother.
After much debugging of the clash between versions of emotion used in storybook and in app, and for those who come after me, I found that storybook has now provided a feature flag to avoid clashing with later versions of emotion: https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#emotion11-quasi-compatibility I tested it and it works well to prevent emotion version-out-of-sync problems in storybook, and is a 3 line change.
See the bottom of https://github.com/storybookjs/storybook/issues/13145 for more details
@GriffinSauce , I didn’t follow up because I’m ashamed of my solution.
Following @shilman 's suggestion, I dug around in my dependencies under the assumption that there were inconsistent versions of either
emotionorreact. I read theyarn.lockfile looking for versions of them, and noticed a few cases where it was resolving counterintuitively:emotion ^10.1would resolve toemotion 10.3, butemotion ^10.2resolved toemotion 10.2.I simply removed those from the
yarn.lock(Warning: you aren’t supposed to hand-edityarn.lock. It makes the maintainers sad) and then reranyarn.This maintained most of my various package versions, but got rid of a metric ton of crud. Fewer versions of
@emotion/coreand@babel/runtimeandreact-foofloating around.This didn’t break anything, and seemed to work well enough.
Great idea @GriffinSauce ! Would you mind contributing a PR for that?
That indeed did it. A little updating of dependencies seemed to clear it up. Thanks!
Thanks, it’s been a ton of fun! 🙏
I’m certain that the issue is due to some kind of conflict, either react or emotion. With a repro we might be able to fiddle with it and see what kind of webpack resolutions voodoo we might need to do to get it fixed. But honestly this stuff is really confusing and I’m not even sure a repro would help – more likely you’d get it figured out yourself trying to disentangle from the monorepo… Wish I had a magic bullet for this!
Ouch. Not really – it’s our core prod, and we’re a monorepo. I could possibly try to split off pieces. Or share our
yarn.lockor something.Also, hey @shilman ! I’d meant to send you a wave at some point – storybook is awesome, and I’m so glad you’re making it happen!
Strange as it is to say, I’m coming in a full year later for upgrading to v6 (!) and seeing the same sorts of errors. Any ways that I can deliver diagnostics against our weird little codebase?
@jdelStrother contact me directly on our discord if the issue persists, so maybe we can debug together.
@ndelangen I’m getting this error when running
rc.5against the example above:@jdelStrother Ok just reproduced in a different test project. Try removing
yarn.lockandnode_modulesand reinstalling. We’ve been seeing a lot of yarn issues lately and I suspect this is one. Please let me know if that works. It’s not a very satisfying solution, but at least it will help us get closer to understanding what’s going on.