storybook: Storybook with builder-webpac5 complains about conflicting values in DefinePlugin and not redefine custom variables
Describe the bug
I am using Storybook6-rc01 with builder-webpack5.
I define several variables with patching webpack config and DefinePlugin through function webpackFinal:
plugins: [
new webpack.DefinePlugin({
"process.env.NODE_ENV": JSON.stringify("development"),
"window.FAKE_GLOBAL_FUNCTION": "(function() { return false; })",
}),
],
Function FAKE_GLOBAL_FUNCTION call is added to test story
But there is error about Conflicting values for 'process.env' in build console and there is error on rendered story on UI about window.FAKE_GLOBAL_FUNCTION is not defined
To Reproduce Steps to reproduce the behavior:
- Go to https://github.com/khats/storybook-demo
- Pull project
- Install dependencies with
yarn - Start storybook with
yarn start-storybook
Expected behavior
- No error in build console:
Conflicting values for 'process.env' '{NODE_ENV: "development", NODE_PATH: [], STORYBOOK: "true", PUBLIC_URL: "."}' !== '{}' - window. FAKE_GLOBAL_FUNCTION is defined and story is rendered without error
Screenshots


Code snippets If applicable, add code samples to help explain your problem.
System Environment Info:
System: OS: macOS 11.0.1 CPU: (12) x64 Intel® Core™ i7-9750H CPU @ 2.60GHz Binaries: Node: 14.15.3 - ~/.nvm/versions/node/v14.15.3/bin/node Yarn: 2.4.0 - /usr/local/bin/yarn npm: 6.14.9 - ~/.nvm/versions/node/v14.15.3/bin/npm Browsers: Chrome: 89.0.4389.90 Firefox: 76.0.1 Safari: 14.0.1
Additional context Add any other context about the problem here.
┆Issue is synchronized with this Asana task by Unito
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 20
- Comments: 61 (14 by maintainers)
Storybook
v6.5.12Angularv14.2.2I’m seeing this warning as well, but SB seems to run fine.
webpack5installed as a dev dependency in the workspace.angular.json.Hi, any update regarding this issue? Storybook version:
6.5.9I am using Angular 13 with@storybook/angularand@storybook/builder-webpack5without any manually added plugin, but how should I fix it? Thanks.hi @khats thanks for the quick response, I’m talking about this issue
Also the build is stuck at 99%
Still seeing “Conflicting values for process.env” 😞 . Upgraded from 6.2.9 to 6.3.4:
Great Caesar’s ghost!! I just released https://github.com/storybookjs/storybook/releases/tag/v6.3.1 containing PR #15365 that references this issue. Upgrade today to the
@latestNPM tag to try it out!Is this because of: https://github.com/storybookjs/storybook/blob/75e2b73964dab1e10576ad6b43fbb4f5bf0e3640/lib/core-server/src/manager/manager-webpack.config.ts#L109?
According to the Webpack docs, one should avoid overriding upper-level portions of process: https://webpack.js.org/plugins/define-plugin/.
@WalterWeidner since I’m using storybook with angular, all of them stand out for me 😅
Hey guys, I was able to overcome the
build warning issuewith the solution from this thread: https://github.com/storybookjs/storybook/issues/6763#issuecomment-491415516Like this:
💪
We’re seeing this error with
6.3.6.Also looking for work around for this issue.
Hey everyone, is there any temporary work around for this issue?
I have the same issue as well, Storybook works nonetheless, but the live reload is not working when doing edits to components. I need to manually refresh the Storybook webpage in order to see my changes.
confirming for 6.3.10 and 6.3.12
I still see this warning with Storybook 6.3.8. (node 14.17.6)
Seeing this error with Storybook 6.3.7. I’m using node 14.17.0
still present, i just tested with
6.4.0-alpha.1@shilman Same here, I played with
6.4.0-alpha.0yesterday and still have the waning without .env file.Yes. I still get the warning without the .env file. I’ve completely removed the file for now (the .env file is only used for a separate CLI tool that doesn’t touch Storybook) to remove it from the equation.
@WalterWeidner did you even get the warning when you removed your .env file?
@shilman the empty define plugin doesn’t exist any more in
6.4.0-alpha.0but I still get that warning aboutprocess.env.I was adding my own define like so:
but I removed it and still got the warning (even after clearing node_modules/.cache).
@WalterWeidner please give
6.4.0-alpha.0a try which should fix the problem when there’s no.envfile. If that works, I’ll patch it back to6.3.x.We’re also seeing this behavior in our private repository (using builder-webpack5). We have Webpack 5.38.1 as a direct dependency at the root of our repository (no fancy monorepo setup here).
This is the config as it comes through storybook’s
main.js:I was seeing stuff from our .env file in the second define plugin and removed the file to see if it would go away completely but I was left with the empty object. We’re not even using the .env as this part of the build so it seems something in Storybook is picking up our .env file.
@dewinterjack Have you solved the error?
I tried to add
process/browseras suggested here to storybooksmain.js, but without any luck.additionally when running
build-storybookthe task gets stuck and never finish, even though the files are created instorybook-staticfolderRemoving the yarn resolutions removed the error on
build-storybookandstorybookhowever I am still having an issue withprocessnot being defined@shilman i have updated original linked project to 6.3-beta.10
we are running into this issue as well when using yarn resolutions for webpack 5 in our workspaces monorepo