-
-
Notifications
You must be signed in to change notification settings - Fork 608
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
Unknown argument: --env #1216
Comments
I am having the exact same problem with the |
Please don't install In |
I'm seeing this issue in the 4.0.0 release |
Hi, @robertlevy we've changed the env flag format in v4 because we changed the arg parser, new docs will be released on official site soon. Meanwhile, you can use CLI docs from this deployment - https://vercel.com/webpack-docs/webpack-js-org/e6mjiydwu |
@anshumanv thanks but that link is not working for me. could you paste a summary or working example? |
@robertlevy ofcourse! You should get a good idea from this test - https://github.com/webpack/webpack-cli/blob/master/test/config/type/function-with-env/function-with-env.test.js Let us know if you run into any problems 😄 |
@anshumanv |
@thealjey-eib You can pass any arbitrary string from the command line. |
@snitin315 how? it used to be as simple as this creates variables with names |
@thealjey-eib for now yes, this is how the behaviour was restored when it was removed. You can use webpack --env appFoobar --env titleQwerty And use these variables to write conditional logic in your config, does it not cover your use case? If not, please give an example. |
I am used to do it this way: npx webpack --mode production --config webpack.config.build.js --env.name="[staging|production]" --env.service="[login|flight|reservation|...]" Now I get What's the working equivalent in Webpack CLI 4.x and Webpack 5.x? When I change the syntax to your example, the properties in npx webpack --mode production --config webpack.config.build.js --env name="[staging|production]" --env service="[login|flight|reservation|...]"
# Result in env
{ 'service=staging': true, 'name=login': true } But that's not what I need. |
Thanks for the examples, migration of both config and scripts to use booleans will add a considerable overhead and current format seems not the most verbose thing to work with. I've opened #1932 to track it, will PR soon Since we've migrated our arg parser to commander so |
Yeah, of course. Thanks! |
@anshumanv my example is a multi-application project |
If you have a config per application, you can use flag |
I don't want a config per application either, because they would all be the same. |
Ah okay so you have a single config for all applications, then |
The documentation still has the old format, I've just had the same problem for following the docs: |
@evolopment Maybe you can help fixing it :) Here's the source page https://github.com/webpack/webpack.js.org/blob/master/src/content/guides/environment-variables.md to edit. |
PR sent. Thanks. |
Can there be some easy to find simple fix for this? A lot of people are going to be running into this now, I read the comments and I'm still not sure what the exact fix is |
@cranphin see #1939 for new |
This is a breaking change that really needs to be called out as such. In addition, I don't think webpack-cli 4.x can claim compatibility with webpack v4 with this change -- the |
So, setting up the enviroment variables like this is the way to go: |
@AsebWebDev yep exactly! |
* Upgrades `webpack-cli` from v3.3.10 to v4.9.2 * [CHANGELOG](https://github.com/webpack/webpack-cli/blob/webpack-cli%404.9.2/CHANGELOG.md) * `webpack-cli` changed the way that the `--env` flag is parsed. See webpack/webpack-cli#1216 for more information. * Upgrades `webpack-dev-server` from v3.11.2 to v4.7.4 * [CHANGELOG](https://github.com/webpack/webpack-dev-server/blob/v4.7.4/CHANGELOG.md) * [Migration guide](https://github.com/webpack/webpack-dev-server/blob/master/migration-v4.md) Resolves opensearch-project#1065 Signed-off-by: Tommy Markley <[email protected]>
* Upgrades `webpack-cli` from v3.3.10 to v4.9.2 * [CHANGELOG](https://github.com/webpack/webpack-cli/blob/webpack-cli%404.9.2/CHANGELOG.md) * `webpack-cli` changed the way that the `--env` flag is parsed. See webpack/webpack-cli#1216 for more information. * Upgrades `webpack-dev-server` from v3.11.2 to v4.7.4 * [CHANGELOG](https://github.com/webpack/webpack-dev-server/blob/v4.7.4/CHANGELOG.md) * [Migration guide](https://github.com/webpack/webpack-dev-server/blob/master/migration-v4.md) Resolves #1065 Signed-off-by: Tommy Markley <[email protected]>
I have installed git for angular in vs code and after installing, ng serve shows unknown argument: serve |
Please open an issue in angular-cli repo |
(with versions "webpack": "^5.73.0" and "webpack-cli": "^4.10.0") This solved the issue for me: /package.json --> Hope it helps. |
Describe the bug
I'm trying to set my webpack
env
for configuration purposes withBut,
webpack-cli
keeps throwing⬢ webpack: Unknown argument: --env
error to meWhat is the current behavior?
webpack-cli
refuses to read the flag and throw an error insteadTo Reproduce
Steps to reproduce the behavior:
Just try to add
--env
flag to anywebpack
command.Expected behavior
webpack-cli
should accept and set this variable correctlyScreenshots
Additional context
This works on
3.3.10
. I'm currently using4.0.0-beta.2
The text was updated successfully, but these errors were encountered: