Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VSCode Remote Debug 導入してみる #4

Closed
mizdra opened this issue Jul 9, 2022 · 3 comments
Closed

VSCode Remote Debug 導入してみる #4

mizdra opened this issue Jul 9, 2022 · 3 comments

Comments

@mizdra
Copy link
Collaborator

mizdra commented Jul 9, 2022

from: #1

AWS インスタンス上で動いている Node.js アプリケーションを、手元の VSCode で breakpoint を仕掛けながら step 実行したいので、やってみる。

@mizdra
Copy link
Collaborator Author

mizdra commented Jul 9, 2022

まず Node.js アプリケーションを --inspect を付けて起動するよう変更。これでインスタンス上の Node.js アプリケーションが、9229 port をデバッグ用のポートとして公開するようになる。

次に .ssh/config で ポートフォワードの設定をする。リモートの 9229 port をローカルの 9229 に繋ぐ。

# ~/.ssh/config
Host 52.68.207.4
  AddKeysToAgent yes
  UseKeychain yes
  IdentityFile ~/.ssh/isucon11-qualify.pem
  LocalForward 9229 127.0.0.1:9229
  LocalForward 5000 127.0.0.1:5000

Host 13.231.217.189
  AddKeysToAgent yes
  UseKeychain yes
  IdentityFile ~/.ssh/isucon11-qualify.pem
  LocalForward 9229 127.0.0.1:9229
  LocalForward 5000 127.0.0.1:5000

そして VSCode 向けに debugger の設定を書く。local と remote のソースコードの対応付けができるよう、localRoot と remoteRoot が必要。

sourcemap も吐いておく。これをやっておかないと、*.ts 上で breakpoint を仕掛けても、どの *.js に対応するのか分からなくて、breakpoint が無視されてしまう。inline な sourcemap にしておかないと、local の sourcemap が使われてしまう & local でいちいち npm run build して sourcemap を生成する必要があって面倒なので、inline がオススメ。

@mizdra
Copy link
Collaborator Author

mizdra commented Jul 9, 2022

これで remote で動いている Node.js アプリケーションを step 実行できる。最高!

 2022-07-09 18 42 39

@mizdra
Copy link
Collaborator Author

mizdra commented Jul 9, 2022

導入できた。

@mizdra mizdra closed this as completed Jul 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant