1.node.js をインストールします。
2.Visual Studio Code をインストールします。
3.任意のフォルダにデバッグ対象となる js ファイルを生成します。
(ここでは仮に app.js とします。)
4.Visual Studio Code の「デバッグ」ボタンを押して、「launch.json を開く」ボタンを押します。
5.launch.json の configurations - program に "${workspaceRoot}/app.js" と記述します。
{
// Use IntelliSense to learn about possible Node.js debug attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Launch Program",
"program": "${workspaceRoot}/app.js"
}
]
}
6.Visual Studio Code で app.js を開き、ブレークポイントを設定、もしくは app.js 内に debugger キーワードを記述します。
7.「Launch Program」ボタンをクリックするとデバッグが開始します。
実行結果: