Skip to content
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

[QUESTION] How can I unset env variable when run npm script? #680

Closed
DimaGashko opened this issue Jan 11, 2020 · 3 comments
Closed

[QUESTION] How can I unset env variable when run npm script? #680

DimaGashko opened this issue Jan 11, 2020 · 3 comments

Comments

@DimaGashko
Copy link

What / Why

I have some npm scripts. Some of them use env variables. For example (just example):

"scripts": {
    "start": "webpack --watch --env.noSourceMaps",
  },

So, for now, when I call npm start env.noSourceMaps = true

But, how can I unset that variable when run npm start?

If I run npm run -- --env.noSourceMaps=false I got env.noSourceMaps = [true, 'false']

If I run npm run -- --env.noSourceMaps I got env.noSourceMaps = [true, true]

If I run npm run -- --env.noSourceMaps= I got env.noSourceMaps = [true, '']

But I want env.noSourceMaps = false or undefined

And I do not want to reverse logic (I mean, i don't want to use it as "start": "webpack --watch" and call it as npm start or npm start -- --env.noSouceMaps or "start": "webpack --watch", "start:noMaps": "webpack --watch --env.noSourceMaps")

@ljharb
Copy link
Contributor

ljharb commented Jan 11, 2020

you can't, unless webpack allows you to do it.

@ljharb
Copy link
Contributor

ljharb commented Jan 11, 2020

In other words, if you want to call a script with a passthrough arg, the script can't already have defined that arg.

@DimaGashko
Copy link
Author

@ljharb Got it, Thanks for answering.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants