Skip to content
IntelliJでのnodejs-expressのdockerリモートデバッグ設定
web-tips
2019-09-24

開発環境前提(セキュリティ関係はなし状態),サーバー側は docker-composeとnodemonで実行

サーバー側のdocker-compose.yml内の nodemon 行にinspect項を追加。port 9229を通す

app:
・・・
  ports:
    - "0.0.0.0:9000:9000"
    - "0.0.0.0:9229:9229"
  command: sh -c "・・・ nodemon --inspect=0.0.0.0:9229 ・・・"
app:
・・・
  ports:
    - "0.0.0.0:9000:9000"
    - "0.0.0.0:9229:9229"
  command: sh -c "・・・ nodemon --inspect=0.0.0.0:9229 ・・・"

ローカルのIntelliJ側は Run/Debug Configuration で Attach to Node.js/Chrome を選んでデバッグ実行

つながらないときは サーバー側に
Debugger listening on ws://0.0.0.0:9229/b4f8874b-e433-429c-8e61-1xxxxx などのログが出ているので websocket がつながるか別のツールで確認する(wscatなど)