node.script Reference

Control a local Node.js process from Max



Control a local Node.js process from Max. Messages preceded by script control the lifecycle of the Node script (start to start, stop to stop). Other messages will be sent to the process directly.


Node is a JavaScript framework for writing applications. To learn more about Node, visit their website

Some Max patchers will want to do things that are difficult to do from Max. For example, it might be desirable to pull some data from a web address, then parse and analyze that data to generate synthesis parameters. Or, one might want to watch a local folder for files, triggering some action inside Max when the contents of that folder change. For these kinds of long-running tasks, which may require some kind of complex, persistent state, Node can be a very useful tool.

Another reason to use Node is to take advantage of the wealth of open source modules registered with the Node Package Manager (NPM). These packages contain libraries of JavaScript code for doing everything from parsing dates, to training neural nets, to running a web server, to writing chord progressions and much more. Node for Max helps make these resources available to Max programmers.

To communicate with Max, the Node script uses the "max-api" Node module. This set of functions simplifies the process of sending data between the Node application and Max. This API can attach handlers to Max messages; parse Max dictionaries into JSON objects; and read, update and set named dictionaries within Max. For examples on how to use this API, see the code examples included with the Node for Max package, as well as the API documentation at


script [symbol]

Entry point for your Node application. Send node.script the start message to start running this script.


args [16 atoms]

Arguments to be passed to the Node script on launch. Note that this attribute is only meaningful in conjunction with the autostart attribute. Otherwise, node.script will use the arguments supplied with the start message.

autostart [int]

Start the Node script automatically, without script start

defer [int]

When false (the default), messages from Node will be processed on the scheduler thread, at the same priority as other Max messages. Activating defer will move processing to the back of the low priority queue, same as the defer attribute on metro

node_bin_path [symbol] (default: )

Override the built in Node executable. Optional. Only use this attribute if you'd like to use a different Node executable from the one included with Max for Node (possibly you want to use an older version for compatibility reasons).

npm_bin_path [symbol] (default: )

Override the built in NPM executable. Optional. Only use this attribute if you'd like to use a different NPM executable from the one included with Max for Node (possibly you want to use an older version for compatibility reasons).

options [16 atoms]


running [int]


Read only: 1 if there is a running Node process, 0 otherwise

watch [int]

True if node.script should relaunch the Node script automatically when the source file changes

Common Box Attributes



Send a bang message to the running Node script









anything [list]
Send a message of any length to the running Node script. Can also be used to send dictionaries, which will automatically be converted to JSON.


Launch the JS documentation


Double-click to reveal the Node script


Reveal the Node script in Finder or Explorer



arguments [list]

Messages beginning with the symbol script are used to start, stop and query the Node process. The symbol following script determines how the message will be handled. Subsequent arguments are passed to that handler, if applicable.

npm - Interface with the Node Package Manager (npm). If the node script is in a node package, then this message can be used to (for example) install module dependencies listed in package.json into node_modules. The npm message assumes that package.json is in the same folder as the script specified as the first argument to node.script. Symbols following npm will be sent as arguments to npm (for example script npm install will run `npm install`).

processStatus - Get a dictionary describing the status of the running Node process (if any)

reboot - Rarely used. Reboot the Node process manager if it has crashed.

running - Returns 1 if there is a running node process, and 0 otherwise

status - Returns a dictionary with information about the installed version of Node

start - Start running the Node script with the given (optional) arguments. Arguments following start will be available as command line arguments to the Node script.

stop - Stop running the Node script



stream [list]
Send a character stream directly to stdin. Anything sent to node.script after stdin will be sent directly to standard input of the running node script. Note that Max will add a newline character to the end of whatever message is sent.