microsoft / microsoft/nodejstools

How to set environment variables when running node.js app in vs2019

Open
#2,331 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C#
Stars
1.8k
Forks
355
PR merge metrics
No merged PRs in 30d

Description

I have a very simple node.js console app that most of the time and others on our team run in vsCode. This is just a folder with an index.js and package.json.

I would like to run this in visual studio. The problem I'm having is how to configure the environment variables and command line options. In vsCode we have a configuration in launch.json that defines things, this works good in vsCode.

But in visual studio I'm not sure how to set these. I have tried to set values in launch.vs.json but I'm not seeing the environment variables loading.

{
"version": "0.2.1",
"defaults": {},
"configurations": [
{
"type": "nodeDbg",
"name": "Test.1",
"project": "index.js",
"projectTarget": "index.js",
"environment": {
"TEST_ENV": "test"
},
"args": [ "--JobKey=x", "--OverrideOrganizationId=y" ]
}
]
}

I'm not seeing the environment variables or args populating. Is this the correct way to set these? Different tags?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the reported launch.vs.json configuration for the index.js app and compare it with the working VS Code launch.json setup. Reproduce the run in Visual Studio 2019, checking whether the environment value TEST_ENV and the two command-line arguments reach the app. Done means both environment variables and arguments are available when debugging.

Written by the indexing model from the issue text.

Assessment

Tech stack
node.js
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.