Press F5 in vscode, you can select node environment to execute JavaScript
Set F5 to execute the current file
In the root directory of the new .vscode
folder, the new file launch.json
write the following configuration
Key changes: "program": "${file}"
{
// 使用 IntelliSense 了解相关属性。
// 悬停以查看现有属性的描述。
// 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "启动程序",
"skipFiles": [
"<node_internals>/**"
],
"program": "${file}"
}
]
}
Set a breakpoint, press F5, you can see the variables in the sidebar, and check the output in the debug console below