Debug applications in NodeJS [closed]

0

What are the best tools for debugging applications in your opinion?

    
asked by anonymous 13.12.2013 / 12:48

4 answers

11

The node itself already has a debug tool, just run your node module as follows:

node debug nome_do_seu_modulo

Follow the documentation to see how it works: link

But there is node-inspector that allows you to use the browser to debug. Just start the debugger and access the url in the browser. Following documentation: link

Using the Node Inspector

Install via npm:

$ npm install -g node-inspector

Start the debugger:

node-inspector

Launch your app in debug mode:

$ node --debug your/short/node/script.js

Or start saying to pause on the first line:

$ node --debug-brk your/short/node/script.js

Access the url:

http://127.0.0.1:8080/debug?port=5858

All you have to do is debug your browser!

Using the node debugger

Launch your app in debug mode:

node debug meu_app

At this point the debugger will stop at the first line, then it will only debug. Here are some commands:

cont, c - Continue execution
next, n - Step next
step, s - Step in
out, o - Step out
pause - Pause running code (like pause button in Developer Tools)

You can also monitor the value of variables:

watch( "nome_da_variavel")

In this way, with each step that is given, it will print on the console the value of the observed variables.

You can also write expressions, just use the command repl and enter the expressions. To return, type Ctrl + C.

See the documentation for more details on the commands.

    
13.12.2013 / 13:21
5

In addition to the node debugger recently released Node.js Tools for Visual Studio .

The add-on looks promising and, in my opinion, Visual Studio is one of the best IDE for debugar that exists ... I recommend taking a look.

    
13.12.2013 / 12:56
3

Node has a debugger , which you run like this:

node debug myscript.js
    
13.12.2013 / 12:50
3

I use JetBrains IDEs for Java, Ruby and Node.js (I use the Node plugin in RubyMine). So I usually use the debugger in IDE itself. link

    
13.12.2013 / 13:30