storybook: Storybook 5.0.0 emotion-themeing and React loader bug
Describe the bug When starting up Storybook 5.0.0-rc.8 see the following error:
info @storybook/react v5.0.0-rc.8
info
info => Loading static files from: /Users/afrankel/Code/makana-platform/nani/public .
info => Loading presets
WARN Failed to load preset: "/Users/afrankel/Code/makana-platform/nani/node_modules/@storybook/core/dist/server/manager/manager-preset.js"
ERR! Error: Cannot find module 'emotion-theming/package.json'
ERR! at Function.Module._resolveFilename (internal/modules/cjs/loader.js:594:15)
ERR! at Function.resolve (internal/modules/cjs/helpers.js:30:19)
ERR! at Object.<anonymous> (/Users/afrankel/Code/makana-platform/nani/node_modules/@storybook/ui/paths.js:16:38)
ERR! at Module._compile (internal/modules/cjs/loader.js:702:30)
To Reproduce
- yarn
- yarn storybook
Expected behavior Starts up without issue
Additional context
Adding yarn add emotion-theming@^10.0.7 -D to project gets past this error
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 38
- Comments: 42 (9 by maintainers)
Commits related to this issue
- Update lockfile to fix breaking storybook build https://github.com/storybooks/storybook/issues/5817 — committed to youseedk/dna-react by havgry 5 years ago
- fix: add storybook package to help with missing dep Ref: https://github.com/storybookjs/storybook/issues/5817 — committed to agrc/roadkill-mobile by stdavis 3 years ago
- fix: add storybook package to help with missing dep Ref: https://github.com/storybookjs/storybook/issues/5817 — committed to agrc/roadkill-mobile by stdavis 3 years ago
- fix: add storybook package to help with missing dep Ref: https://github.com/storybookjs/storybook/issues/5817 — committed to agrc/roadkill-mobile by stdavis 3 years ago
Worked for us to add
@storybook/themingas an explicit dependencyAnother update: If you don’t want to delete your
package-lock.json,npm dedupeseems to have solved the issue for me.We encountered the same issue after an upgrade from v5.0.3 to v5.0.5.
Resolved with:
yarn add --dev @storybook/themingI also had this issue with
@storybook/react: 5.0.3MacOs Mojave Resolved with:Update: Noticed this when running
npm ls @emotion/coreafter the above steps:@emotion/coreisn’t being hoisted to the root, where the build is expecting it (it’s extraneous because it’s no longer in mypackage.json).require.resolveis called in@storybook/ui/paths.js, but it’s only installed under@storybook/theming, so it’s nested in thenode_modulesin that folder, which means that therequire.resolvein@storybook/uican’t find it.I want to say the solution is to add
@emotion/{core,styled}as a dependency to@storybook/ui, since@storybook/uiis looking for it.I have the same thing with
@storybook/react@5.0.0edit: 3rd time deleting package-lock.json & node_modules did the trick for me
Removing the
yarn.lockfile was not an option for me (and I would recommend against doing that in most cases). We were able to fix it by…hope this helps anyone else running into this issue
I have the same issue and couldn’t resolve it by deleting the yarn.lock
Have the same issue here in @storybook/react@5.0.0 running on Mac OSX However removing yarn.lock file is not an option in our process
Had the same problem with storybook@5.0.0, homburg solution worked for me
yarn add @emotion/core @emotion/styledimmediately resolved it thoughAlpha version fixed the issue for me, thanks @shilman !
I am still getting this issue. I have the latest of the following:
@storybook/theming@emotion/core@emotion/styledAll the cache clearing did not work. It is still trying to find the old
emotion-themingpackage:I installed
emotion-themingpackage and everything is working…Maybe the issue is related to two different emotion versions being used by storybook/core and storybook/theming. This is all very weird, I just can’t get past this. When I install the emotion libraries manually, it builds, but I get errors in the browser (
Cannot read property 'Consumer' of undefined at ThemeProvider) and nothing renders.It worked in a pristine CRA app, but in my custom Webpack setup it doesn’t. I am trying to setup storybooks for our React Native Web component library. Here’s my test repo: https://github.com/MrLoh/universal-react-storybook
I was getting some really weird emotion related errors. Deleting node_modules, yarn.lock and running
yarn cache cleanbefore installing fixed the issue for me.@afrankel-sfdo I’m seeing the same issue. My current theory is the lack of
@emotion/corecauses theModuleParseError. I rannpm i @emotion/core @emotion/styledwhich seemed to resolve the issue. Weirdly, I did notice that those two deps are removed from thepackage-lock.json, although I have no idea why. I removed them from thepackage.jsonand left thepackage-lock.jsonwith them, and I think I’m back in business, although it doesn’t really explain what happened.@shilman Not sure what the storybook release schedule is (e.g. for 5.1.x), but this is blocking a number of projects upgrading to storybook 5, so I’d love for this fix to hit some non-alpha release if possible 🙂
@BrendanAnnable @alexlafroscia @devrelm Should I patch the fix back into
5.0.x?same issue on
5.0.0and I also noticed low down…A fresh storybook install works fine, haven’t tracked down what in our project might be causing these issues.
@afrankel-sfdo Can you remove
node_modulesandyarn.lockand try again? We’ve been seeing a lot of weirdness around stuff like this, e.g. https://github.com/storybooks/frontpage/pull/28#issuecomment-468666553The problem here is that yarn (or npm) is weirdly (in this case, not) hoisting packages.
yarn listoryarn whyoutputs are faulty too:As you can see, yarn is reporting that there’s only one
emotion-themingpackage, which should be hoisted to root, but it’s not the case: It’s duplicating the package in 4 places across different packages. Whether it’s a yarn/npm bug, I’m not sure. Maybe the combination of dependencies’dependenciesandpeerDependenciesis causing this weird behavior? My storybook setup fails when I have different major versions of storybooks packages, e.g.@storybook/react@5.0.10and@storybook/react-native@4.1.18side by side.I also think that our combination of having a monorepo yarn workspace and top-level nohoisting could also be factors in causing this problem:
Egads!! I just released https://github.com/storybooks/storybook/releases/tag/v5.1.0-alpha.23 containing PR #6435 that references this issue. Upgrade today to try it out!
Because it’s a pre-release you can find it on the
@nextNPM tag.Closing this issue. Please re-open if you think there’s still more to do.
Fixed it just like @alexreardon, by installing
emotion-theming: https://emotion.sh/docs/emotion-theming was getting the following error:I just encountered same problem on Mac OSX, on Windows everything works fine on Mac I had to run
npm i @emotion/core @emotion/styledto make it work@MrLoh
I also encountered this issue ( I use
@storybook/vuethough). And I found that one of the packages inpackage.jsondepended on old@storybook/addonspackage which depended on old@emotion/*package internally.As a workaround, I wrote
resolutionsfield for that library, and that solved the issue for me.