Skip to content

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

Description

@DimaGashko

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")

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions