For example, I want to add some breakpoints on the internal file _http_server.js
,but the file does not really exist on my disk.
What should I do?
A minimal CLI debugger is available with node inspect myscript.js . Several commercial and open source tools can also connect to the Node.js Inspector.
Logging using the console module. The most common way to log in Node. js is by using methods on the console module (such as log() ). It's adequate for basic debugging, and it's already present in the global scope of any Node.
NODE_DEBUG enables debugging messages using the Node. js util. debuglog (see below), but also consult the documentation of your primary modules and frameworks to discover further options.
Node JS Web Server internally maintains a Limited Thread pool to provide services to the Client Requests. Node JS Web Server receives those requests and places them into a Queue. It is known as “Event Queue”. Node JS Web Server internally has a Component, known as “Event Loop”.
Yeah, at compile time the .js
files in the source get packed into the node
executable, which makes me unsure if/how you can set breakpoints at all on there.
What worked for me:
.js
file from a checkout of the node source code to the current directory, e.g., readline.js
require('readline')
to require('./readline')
node --expose-internals
flag to allow the copied .js
file to still require('internal/…')
console.log
statements / debugger on the now-local file to figure out what was happeningIf you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With