最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Make VS code choose Node.js environment by default when debugging js code - Stack Overflow

programmeradmin5浏览0评论

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

Share Improve this question edited May 21, 2020 at 3:04 user3848207 asked May 21, 2020 at 2:07 user3848207user3848207 5,03724 gold badges70 silver badges124 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 5

I 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.

发布评论

评论列表(0)

  1. 暂无评论