How to connect to a remote nodejs debug session using PhpStorm / WebStorm?

k0p*_*kus 2 remote-debugging node.js webstorm docker docker-compose

There appears to be a similar question as it about the predecessor to inspect, and I want to use inspect.

I have created a basic docker-compose stack from which I run my nodejs application. I want to listen for the debugger session and debug my JavaScript code within my local WebStorm.

I enter the container via

docker exec -it my_container bash
Run Code Online (Sandbox Code Playgroud)

And I call my nodejs script with the debugger running via inspect:

node --inspect ./cli.js start mytask
Debugger listening on ws://127.0.0.1:9229/81006264-163c-40d7-bd75-64c5e4fca618
For help see https://nodejs.org/en/docs/inspector
Run Code Online (Sandbox Code Playgroud)

The linked help is not helpful to me as it assumes that I want to use the inspect for a local run:

JetBrains WebStorm 2017.1+ and other JetBrains IDEs Create a new Node.js debug configuration and hit Debug. --inspect will be used by default for Node.js 7+. To disable uncheck js.debugger.node.use.inspect in the IDE Registry.

I want to attach to the run inside the docker container from my host WebStorm.

So when I run the script, it just completes never hitting any breakpoint.

I suppose I have to listen to the debugger, yet I do not know how.

I want my local WebStorm to connect to the nodejs debugger. I want to be able to debug within WebStorm as if I have run the nodejs script through WebStorm itself.

I tried digging through the docs yet I am unsure how to follow the guidelines.

I have exposed the default debug port 9229 to my local machine in my docker-compose.yml:

version: "3"
services:
    my_container:
        build: .
        command: "bash"
        hostname: my_container
        tty: true
        environment:
            TERM: xterm
        ports:
            - "9229:9229"
Run Code Online (Sandbox Code Playgroud)

I have no idea on how to listen to the nodejs debugger in WebStorm.

len*_*ena 5

您必须使用node --inspect-brk=0.0.0.0:9229(0.0.0.0是必需的,因为默认情况下 Node.js 仅绑定到本地主机)启动您的应用程序,然后使用附加到 Node.js/Chrome运行配置来附加调试器。端口应设置为9229