New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Webpack5: start-storybook
fails when .env
is present
#14403
Comments
start-storybook
fails when .env
is present and Webpack 5 builder is usedstart-storybook
fails when .env
is present
I am also facing this issue. Is there a temporary fix for this? |
The workaround is to add |
to win over the outdated one used in storybook, which does not support webpack 5. (see storybookjs/storybook#14403)
Thanks for tracking this down @paulrosania @michael-woodward-spok. Since this is a hoisting issue, I'm not sure whether there's much more we can do other than perhaps document the workaround better. Any ideas? |
I think it's worth trying @paulrosania's suggestion:
|
@shilman I think Storybook can solve this, since the hoisting issue is caused by incompatible I believe this issue would be resolved if all versions of Here's the tree in our repository, for example:
I'm happy to post a PR if that would be helpful! Let me know. |
@paulrosania Totally missed that part! Yes please create a PR and let's see what happens. 🙏🙏🙏 |
I put up a PR. The new library version seems to work fine without code changes; it appears the major version bumps were related to dropping very old Node versions that are already unsupported by Storybook. |
Olé!! I just released https://github.com/storybookjs/storybook/releases/tag/v6.2.4 containing PR #14492 that references this issue. Upgrade today to the
Closing this issue. Please re-open if you think there's still more to do. |
@shilman The PR seems to be reverted. Is there some issue? I am renaming my .env file for now :( |
@TheFirstMe yes, the PR caused storybook to break for a bunch of people so I'm waiting for a better fix. I've re-opened this issue. |
- Fix breaking changes for husky and eslint-config-prettier - Remove the .ts extension from several imports (typescript doesn't like it) - Update react-spring - Update calls to faker.random - Add dotenv-webpack as our own dev dependency to win over the outdated one used in storybook, which does not support webpack 5. (see storybookjs/storybook#14403)
- Fix breaking changes for husky and eslint-config-prettier - Remove the .ts extension from several imports (typescript doesn't like it) - Update react-spring - Update calls to faker.random - Add dotenv-webpack as our own dev dependency to win over the outdated one used in storybook, which does not support webpack 5. (see storybookjs/storybook#14403)
storybookjs/storybook#14497 and storybookjs/storybook#14403 tl;dr: Happo stopped working after #818 was merged, it turns out it is because `npm run build-storybook` crashed due to the above issue(s). Theoretically this is a workaround and can be removed after storybookjs/storybook#14403 is resolved, but there is no sign of when that'll happen Deep technical reasons from the linked issue for why this fails: > If npm hoists dotenv-webpack 6.0.4 to the node_modules root, everything works fine. However, if npm hoists dotenv-webpack 1.8, and the user has a .env file present, start-storybook fails to run. > > Unless the user is already pinning dotenv-webpack, the version that gets hoisted depends on how many dependencies are using 1.8 vs 6.0.4. (For example, in the repro steps below, if you remove @storybook/addon-essentials, npm hoists 6.0.4 and things work normally.) This makes for some extremely surprising and hard-to-pin-down behavior.
storybookjs/storybook#14497 and storybookjs/storybook#14403 tl;dr: Happo stopped working after #818 was merged, it turns out it is because `npm run build-storybook` crashed due to the above issue(s). Theoretically this is a workaround and can be removed after storybookjs/storybook#14403 is resolved, but there is no sign of when that'll happen Deep technical reasons from the linked issue for why this fails: > If npm hoists dotenv-webpack 6.0.4 to the node_modules root, everything works fine. However, if npm hoists dotenv-webpack 1.8, and the user has a .env file present, start-storybook fails to run. > > Unless the user is already pinning dotenv-webpack, the version that gets hoisted depends on how many dependencies are using 1.8 vs 6.0.4. (For example, in the repro steps below, if you remove @storybook/addon-essentials, npm hoists 6.0.4 and things work normally.) This makes for some extremely surprising and hard-to-pin-down behavior.
Describe the bug
This was a doozy to track down! 😅 The gist is, you get a failure with a strange error if you have a
.env
file under the rightnpm
conditions. This happens because@storybook/builder-webpack4
and@storybook/core-server
depend ondotenv-webpack
1.8, which does not support Webpack 5.If
npm
hoistsdotenv-webpack
6.0.4 to thenode_modules
root, everything works fine. However, ifnpm
hoistsdotenv-webpack
1.8, and the user has a.env
file present,start-storybook
fails to run.Unless the user is already pinning
dotenv-webpack
, the version that gets hoisted depends on how many dependencies are using 1.8 vs 6.0.4. (For example, in the repro steps below, if you remove@storybook/addon-essentials
,npm
hoists 6.0.4 and things work normally.) This makes for some extremely surprising and hard-to-pin-down behavior.I believe the proper remedy is to update all Storybook libraries that depend on
dotenv-webpack
to v6, which supports Webpack 4 and 5. I am happy to open a PR if desired.For context, here is the error when the wrong version of
dotenv-webpack
is hoisted:To Reproduce
Steps to reproduce the behavior:
Expected behavior
Storybook should start.
System
┆Issue is synchronized with this Asana task by Unito
The text was updated successfully, but these errors were encountered: