2
5

More than 3 years have passed since last update.

visual studio code で、babel-node(@babel/node)をデバッグ

Last updated at Posted at 2019-11-08

確認した環境

visual studio code: 1.39.2
babel-node: 7.2.2

launch.jsonを開く

画面右端からデバッグアイコンをクリックし、デバッグの設定アイコンをクリック、プルダウンリストから「Node.js」を選択すると、デフォルトのlaunch.jsonが表示されます。
sas.gif
デフォルトのlaunch.json

{
    // IntelliSense を使用して利用可能な属性を学べます。
    // 既存の属性の説明をホバーして表示します。
    // 詳細情報は次を確認してください: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "type": "node",
            "request": "launch",
            "name": "プログラムの起動",
            "program": "${file}"
        }
    ]
}

launch.jsonを編集

launch.jsonに以下のように編集します。※メインのjsがindex.jsである前提です。異なる場合は、"program"の値を書き換えてください。

{
    // IntelliSense を使用して利用可能な属性を学べます。
    // 既存の属性の説明をホバーして表示します。
    // 詳細情報は次を確認してください: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "type": "node",
            "request": "launch",
            "name": "babel-nodeのデバッグ",
            "program": "${workspaceFolder}/index.js",
            "runtimeExecutable": "${workspaceFolder}/node_modules/.bin/babel-node",
        }
    ]
}

デバッグの実行

画面右端からデバッグアイコンをクリックし、上で編集した設定名("name")が選択されているのを確認し、デバッグの開始アイコンをクリックします。
qq.gif

2
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
5