Skip to content

"Launch NPM" ignores custom environment variables #949

@AndrewFerr

Description

@AndrewFerr

For "Launch NPM" run configurations, any environment variables set in the "Environment" tab are not passed to the launched npm process or its children.

To reproduce, create a package.json with a script that prints its environment:

{
  "scripts": {
    "envtest": "node -e 'console.log(process.env)'"
  }
}

Then, create a "Launch NPM" configuration for this script, add some variables to the "Environment" tab, and run it. The resulting output won't show any of the variables you set. Meanwhile, running the same script from within a console will print any variables passed to it, like with VAR=VALUE npm run envtest or export VAR=VALUE; npm run envtest.

A workaround is to use an External Tool Configuration to handle launching NPM, which passes environment variables as expected. (It also offers a few other benefits, but that's a story for another issue 🙂 )

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions