question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Storybook with builder-webpac5 complains about conflicting values in DefinePlugin and not redefine custom variables

See original GitHub issue

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:

  1. Go to https://github.com/khats/storybook-demo
  2. Pull project
  3. Install dependencies with yarn
  4. Start storybook with yarn start-storybook

Expected behavior

  1. No error in build console: Conflicting values for 'process.env' '{NODE_ENV: "development", NODE_PATH: [], STORYBOOK: "true", PUBLIC_URL: "."}' !== '{}'
  2. window. FAKE_GLOBAL_FUNCTION is defined and story is rendered without error

Screenshots

image

image

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

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:19
  • Comments:59 (13 by maintainers)

github_iconTop GitHub Comments

9reactions
WodenWang820118commented, Jun 29, 2022

Hi, any update regarding this issue? Storybook version: 6.5.9 I am using Angular 13 with @storybook/angular and @storybook/builder-webpack5 without any manually added plugin, but how should I fix it? Thanks.

8reactions
azangrucommented, Jul 11, 2021

Still seeing “Conflicting values for process.env” 😞 . Upgraded from 6.2.9 to 6.3.4:

image

Read more comments on GitHub >

github_iconTop Results From Across the Web

Storybook with builder-webpac5 complains about conflicting ...
Storybook with builder-webpac5 complains about conflicting values in DefinePlugin and not redefine custom variables #14257. khats posted onGitHub.
Read more >
WARNING in DefinePlugin Conflicting values for 'process.env ...
The DefinePlugin checks that variable when you try to define it for your "run time" (which is different from "build time"), and thus...
Read more >
Environment variables - Storybook - JS.ORG
Environment variables. You can use environment variables in Storybook to change its behavior in different “modes”. If you supply an environment variable ......
Read more >
Environment Variables : Webpack config using DefinePlugin
What is Environment Variable ? “Environment variables are a set of dynamic named values that can affect the way running processes will behave...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found