-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
WARNING in DefinePlugin Conflicting values for 'process.env.NODE_ENV' #7924
Comments
I guess the warning was introduced by #7727 |
I have the same issue after migration to the latest version |
NX@13.3.1 still the same issue. |
Still present in 13.4.3 |
I got this issue with a react app. I don't know how to fix it! |
Same |
I encountered this issue as well, in a project where the Turns out Webpack's Another config option I found helpful was setting [0] https://webpack.js.org/configuration/mode/ |
Still present in 13.83 |
DefinePlugin warning DefinePlugin 大家有没有办法呀 |
this bug is still present in v13.8.4 |
this bug is still present in v13.8.5. Is there any workaround for this for now? |
I'm also having this issue as of upgrading to 13.8.5 And not only am I getting this warning, I also have my react app running with the production environment. My website was contacting the prod api URL and it took me a while to understand why. |
Same issue as others in 13.8.4 and 13.8.5 Workarounds suggested here worked for me: #9241 (comment) Feels like a regression given no code changes give different results between versions. Thanks. |
Done a little more digging and this still happens out of the box using newest versions of
So I suspect this is a bug? |
Spent a good chunk of the weekend using Not sure what those changes were intended to do or if this behaviour is in fact intended functionality (as I'm new to NX). But:
I hope this helps someone more familiar with NX fix this issue. Thanks all! EDIT: Looking closer at the changes in that PR - |
Just piling on. I run into this bug after using create Reach App and immediately trying to install and run storybook. yarn create react-app my-app
cd my-app
npx sb init
yarn storybook debugging:
|
Now we can pass the env vars before passing the command. environment-variables
|
@jeneser confirmed that modifying In context: "scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject",
"storybook": "NODE_ENV=development start-storybook -p 6006 -s public",
"build-storybook": "build-storybook -s public"
}, |
Add |
React Project Configurationproject.json {
"root": "apps/react",
"sourceRoot": "apps/react/src",
"projectType": "application",
// leave out ......
"targets": {
"build": {
"executor": "@nrwl/web:webpack",
"outputs": [
"{options.outputPath}"
],
"defaultConfiguration": "production",
"options": {
// leave out ......
},
"configurations": {
"production": {
"fileReplacements": [
{
"replace": "apps/app-react/src/environments/environment.ts",
"with": "apps/app-react/src/environments/environment.prod.ts"
}
],
"optimization": true,
"outputHashing": "all",
"sourceMap": false,
"namedChunks": false,
"extractLicenses": true,
"vendorChunk": false
},
// add (can be ignored, because this is default)
"development": {
"fileReplacements": [],
"optimization": false,
"outputHashing": "all",
"sourceMap": true,
"namedChunks": false,
"extractLicenses": false,
"vendorChunk": false
}
}
},
"serve": {
"executor": "@nrwl/web:dev-server",
"options": {
// try changing
// "buildTarget": "app-react:build"
// to
"buildTarget": "app-react:build:development",
"hmr": true
},
"configurations": {
"production": {
"buildTarget": "app-react:build:production",
"hmr": false
}
}
}
}
} |
I have tried applying the configuration adjustments, and I've managed to fix it for the λ set NODE_ENV=development && nx serve bd-application--verbose
> nx run bd-application:serve --verbose
<i> [webpack-dev-server] Project is running at:
<i> [webpack-dev-server] Loopback: http://localhost:4203/, http://127.0.0.1:4203/
<i> [webpack-dev-server] 404s will fallback to '/bd/application/managementindex.html'
> NX Web Development Server is listening at http://localhost:4203/bd/application/management
Entrypoint main [big] 6.33 MiB (8.24 MiB) = runtime.js 49.5 KiB main.js 6.28 MiB 3 auxiliary assets
Entrypoint polyfills [big] 480 KiB (577 KiB) = runtime.js 49.5 KiB polyfills.js 431 KiB 2 auxiliary assets
chunk (runtime: runtime) main.js (main) 5.99 MiB (javascript) 148 KiB (asset) [initial] [rendered]
chunk (runtime: runtime) polyfills.js (polyfills) 397 KiB [initial] [rendered]
chunk (runtime: runtime) runtime.js (runtime) 33.3 KiB [entry] [rendered]
WARNING in DefinePlugin
Conflicting values for 'process.env.NODE_ENV'
webpack compiled with 1 warning (b82e2e087893d6f4) {
"root": "apps/bd/application",
"sourceRoot": "apps/bd/application/src",
"projectType": "application",
"targets": {
"build": {
"executor": "@nrwl/web:webpack",
"outputs": ["{options.outputPath}"],
"defaultConfiguration": "development",
"options": {
...
},
"configurations": {
"development": {
...
},
"production": {
...
}
}
},
"serve": {
"executor": "@nrwl/web:dev-server",
"options": {
"buildTarget": "bd-application:build:development",
"port": 4203,
"hmr": true
}
},
...
}
...
}
|
Hi @msageryd @nemonemi, below is my {
"root": "apps/rec",
"sourceRoot": "apps/rec/src",
"projectType": "application",
"targets": {
"build": {
"executor": "@nrwl/web:webpack",
"outputs": ["{options.outputPath}"],
"defaultConfiguration": "production",
"options": {
"compiler": "babel",
"outputPath": "dist/apps/rec",
"index": "apps/rec/src/index.html",
"baseHref": "/",
"main": "apps/rec/src/main.tsx",
"polyfills": "apps/rec/src/polyfills.ts",
"tsConfig": "apps/rec/tsconfig.app.json",
"assets": ["apps/rec/src/favicon.ico", "apps/rec/src/assets"],
"styles": [],
"scripts": [],
"webpackConfig": "@nrwl/react/plugins/webpack"
},
"configurations": {
"production": {
"fileReplacements": [
{
"replace": "apps/rec/src/environments/environment.ts",
"with": "apps/rec/src/environments/environment.prod.ts"
}
],
"optimization": true,
"outputHashing": "all",
"sourceMap": false,
"namedChunks": false,
"extractLicenses": true,
"vendorChunk": false
},
"development": {} // added
}
},
"serve": {
"executor": "@nrwl/web:dev-server",
"options": {
"buildTarget": "rec:build:development", // modified
"hmr": true
},
"configurations": {
"production": {
"buildTarget": "rec:build:production",
"hmr": false
}
}
},
"lint": {
"executor": "@nrwl/linter:eslint",
"outputs": ["{options.outputFile}"],
"options": {
"lintFilePatterns": ["apps/rec/**/*.{ts,tsx,js,jsx}"]
}
},
"test": {
"executor": "@nrwl/jest:jest",
"outputs": ["coverage/apps/rec"],
"options": {
"jestConfig": "apps/rec/jest.config.js",
"passWithNoTests": true
}
}
},
"tags": []
} |
Update: I found what caused the regression. It was due to another fix we did here #8932. The PR to fix this has been opened, just getting a round of review and we should include it in 13.10. |
Still getting this on |
I am seeing this issue when I misconfigure my NODE_ENV and the build configuration, otherwise, I am not seeing the error - 13.9.2 I am also now explicit with the configuration: When I wanna test something else aside from the local "development" I simply set, in windows:
"targets": {
"build": {
"executor": "@nrwl/web:webpack",
"outputs": ["{options.outputPath}"],
"defaultConfiguration": "production",
"options": {
...
},
"configurations": {
"development": {
"optimization": false,
"outputHashing": "all",
"sourceMap": true,
"extractCss": true,
"namedChunks": true,
"vendorChunk": false,
"assets": [
"apps/bd/src/favicon.ico",
"apps/bd/src/assets",
"apps/bd/src/mockServiceWorker.js",
]
},
"qas": {
"optimization": true,
"outputHashing": "all",
"sourceMap": true,
"extractCss": true,
"namedChunks": false,
"extractLicenses": true,
"vendorChunk": false,
"assets": ["apps/bd/src/favicon.ico", "apps/bd/src/assets"]
},
"production": {
"optimization": true,
"outputHashing": "all",
"sourceMap": false,
"extractCss": true,
"namedChunks": false,
"extractLicenses": true,
"vendorChunk": false,
"assets": ["apps/bd/src/favicon.ico", "apps/bd/src/assets"],
"budgets": [
{
"type": "initial",
"maximumWarning": "2mb",
"maximumError": "5mb"
}
]
}
}
},
"serve": {
"executor": "@nrwl/web:dev-server",
"options": {
"buildTarget": "bd:build:development",
"port": 4203,
"hmr": true
},
"configurations": {
"qas": {
"buildTarget": "bd:build:qas",
"hmr": false
},
"production": {
"buildTarget": "bd:build:production",
"hmr": false
}
}
}, |
Followed project config in nrwl/nx#7924 (comment)
I not sure how you guy test THE FIX that you made, Although, I haven't tested on version 13.10 just yet. |
If you're still running into this issue in 13.10 or 14.0, please make sure that:
If you're unsure try creating a new Nx 14 workspace and compare the generated configuration. For example,
There should be no warnings on conflicting If you run into any more problems, please link a reproduction so we can investigate. This issue remains resolved as far as I'm aware. |
FYI The error still occurs on out-of-the-box untouched code:
Tested today. |
I just wanted to setup an angular app with nx-workspace and have the exact issue when running storybook! |
@FloNeu can you please share a reproduction repository, so that I can manage to reproduce your issue and help you? |
It's the |
@mandarini Repro is out of the box. Yes it's just a warning, I would put it way down on the priority list 😁 |
Would love to provide the reproduction - but time is tight right now. But it was just an out-of-the box angular-workspace and setting up storybook for the generated angular-project at nx@latest. |
@FloNeu @prewk as far as Storybook is concerned: This is an issue that appears in the Storybook side. You can check out this reproduction, which is just a pure Angular app (no Nx) with Storybook. The same warning appears. Check out the log here. On Nx, we are using the Storybook builders directly ( Thank you all so much!! :D |
Oh I see, sorry for wasting your time on this! |
Oh no worries at all @prewk !!! It's our job!! No time wasted at all! |
Hi all. Hope this does not look too naive, quite new to Nx here. We had this issue with a newly generated web application (i.e. through By default, app We looked at another existing app (within the same OSS repo) and made the following additions to "serve": {
// ...
"defaultConfiguration": "development",
// ...
"configurations": {
// ...
"development": {
"buildTarget": "XXX-XXX-XXX:build:development"
}
}
} We also added the following "development": {
"buildOptimizer": false,
"optimization": false,
"vendorChunk": true,
"extractLicenses": false,
"sourceMap": true,
"namedChunks": true
} After those changes, the warning went away. HTH |
This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context. |
--publishable
flag.When executing command
yarn nx run my-project:build
got a warning message:I didn't change any default nx settings during nx installation or when creating the project.
The text was updated successfully, but these errors were encountered: