I am using VS code v1.45 to debug a simple nodejs file.
I am testing out a simple node.js file.
var msg = 'Hello World';
console.log(msg);
When I press F5, I get prompted to choose the environment. See screenshot below.
This is a hassle. How do I make VS code choose Node.js environment by default without prompting?
My node.js is installed at C:\Program Files\nodejs\node.exe
I am using VS code v1.45 to debug a simple nodejs file.
I am testing out a simple node.js file.
var msg = 'Hello World';
console.log(msg);
When I press F5, I get prompted to choose the environment. See screenshot below.
This is a hassle. How do I make VS code choose Node.js environment by default without prompting?
My node.js is installed at C:\Program Files\nodejs\node.exe
2 Answers
Reset to default 5I will build on answer by user3848207
Delete any existing launch.json file first. Otherwise, no effect when you click on "create a launch.json file" on the debug panel.
Now, click on "create a launch.json file" on the debug panel found on left-hand side. Then, click Node.js when prompted. Subsequently, Node.js will be the default environment.
Manually edit launch.json
such that "program": "${file}"
. Otherwise, when you press F5, it will run on specific js file and not on actively open file.
launch.json should look like this.
This answer works on VS code v1.45
I will answer my own question.
Click on "create a launch.json file" on the debug panel found on left-hand side. Then, click Node.js when prompted. Subsequently, Node.js will be the default environment.
Credit goes to someone by the name of drunktimelord.