node.js app debug via docker

Hi all. I trying to debug simple js file. 

If I just run it, all is done well, but if I want to debug it (without any breakpoints), it hungs up. How do I setup it so debugger just shuts down after end of js code?

0

Please vote for https://youtrack.jetbrains.com/issue/WEB-56284 to be notified on any progress with it

0

How to use the Node inspector
If you mostly use printf, aka caveman debugging, it can be very difficult to find the right value at the right time.

Things get even worse if you have to rebuild your container image each time you add console.log to it. It could be a lot easier to have the image built once and jump around within it, examining your variables while it’s running. To better understand what we’re gonna do here, I highly suggest to familiarize yourself with the node inspect commands first. CredibleBH Login

To run your Node app in debug mode, simply add inspect after node, something like that:

$ node inspect index.js
< Debugger listening on ws://127.0.0.1:9229/5adb6217-0757-4761-95a2-6af0955d7d25
< For help, see: https: // nodejs . org/en/docs/inspector
< Debugger attached.
Break on start in index.js:1
> 1 (function (exports, require, module, __filename, __dirname) { const http = require('http')
  2 const PORT = process.env.PORT || 3000
  3 
debug> 
When you run your code in inspect mode, it always stops at the first line, waiting for you to interact with it. For those who were brought up using gdb to debug their code, this interface might be compelling. However, if you are used to interacting with your debugger using a GUI, you might want to open up your chrome and navigate to chrome:// inspect.

-1

请先登录再写评论。