Control a local Node.js process from Max. Messages preceded bycontrol the lifecycle of the Node script (start to start, stop to stop). Other messages will be sent to the process directly.
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.
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 https://docs.cycling74.com/maxnode.docs/max-node-api/
Entry point for your Node application. Send node.script the 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 message.
Start the Node script automatically, without
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]
Read only: 1 if there is a running Node process, 0 otherwise
True if node.script should relaunch the Node script automatically when the source file changes
Common Box Attributes
Messages beginning with the symbolare used to start, stop and query the Node process. The symbol following 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 examplewill 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 followingwill be available as command line arguments to the Node script.
stop - Stop running the Node script