Node.debug

Working with the node.debug object

node.debug is a helper utility that eases the process of monitoring and debugging the status of the program running in your node.script object.

To make use of it create a new node.debug object by typing “node.debug” into an empty object box and hitting enter. Connect the rightmost outlet of your node.script object to the left inlet of the node.debug object.

The node.debug object will now capture and handle all lifecycle events and debug messages from the node.script object to which it is connected.

The node.debug object has two displays accessible: monitor and console. You can switch between them by clicking on the icons at the top right or by sending the showtab <monitor|console> message to the object.


The Monitor Tab

The monitor tab shows the main activity of your node.script object. Once you attempt to start a script using script start, the display of node.debug display will change its status:

  • A green panel shows that the program was successfully started.



  • A red panel shows errors that occurred during the startup and provides more information on the failure.



    This error usually contains a stack trace, which will show you where in the program the error occurred. In the example above, we can see that a variable was not defined, and that the error was encountered on line 17, column 1.

    For more details on the Node Error Object and Stack trace see https://nodejs.org/api/errors.html#errors_error_stack

The Monitor Tab also updates when:

  • Your program was restarted due to an error that occurred during the runtime of the program after a successful start.
  • When you are using the @watch attribute to restart whenever you save changes to the code.

A blue info panel will be displayed when you’re using remote debugging and halting the program until a debugger attaches.

A blue panel will be displayed when when you are running npm commands. It will be followed by a green success or red error message.


Stats

At the top of the info panel you can also select Process Stats and Global Stats, which display the information given by a node.script object after sending a script status (bundled Version info, running processes etc) or script processStatus (incl. Memory / CPU Usage etc) message.

status Message

processStatus Message


The Console Tab

The console tab of a node.debug object displays the messages that a node.script has written to its stdout and stderr.

That output is separated by a hint whenever the process started.

Note: This output is different from the output that a Node program can write to the Max console; the node.debug object displays what’s outputted using console.log / console.error in the JavaScript context, whereas writing to the Max console means using the maxApi.outlet() function.


The Bottom Toolbar

The bottom bar of node.debug object gives you access to three simple actions:

  1. When the Console tab is selected, you can clear the output by clicking on the X icon on the left-hand side of the toolbar.

  2. When the monitor tab is selected, you can open your JavaScript program file for editing by clicking on the Edit File icon on the right-hand side of the toolbar.

  3. When the monitor tab is selected, you can display the current directory you’re working in by clicking on the Reveal Working Directory icon on the right-hand side of the toolbar.

See Also

Name Description
Node For Max Documentation - Table of Contents Node For Max Documentation - Table of Contents
Node For Max - Remote Debugging Node For Max - Remote Debugging
node.script