Configure Node.js for ExternalEvaluate

Configure your system to evaluate external JavaScript code with Node.js.

Prerequisites

Node.js must first be installed on your system. Installers for all systems are available from (WebLink[https://www.nodejs.org, https://www.nodejs.org]).

The Node.js package manager, npm, is necessary to install the zeromq sockets package for communication with the Node.js evaluator. Refer to Node.js documentation on how to install npm if it is not available with your installation.

Install zeromq

Once Node.js and npm have been installed, the zeromq package can be installed using npm. By default, npm will install the package to a folder named node_modules, but for (RefLink[ExternalEvaluate, paclet:ref/ExternalEvaluate]) to find the installation, it needs to be placed in a directory called .node_modules in the home directory:

$ cd ~
$ npm install zeromq
$ mv node_modules .node_modules

On Windows, this is the equivalent command to install zeromq:

> cd %HOME%
> npm.exe install zeromq
> ren node_modules .node_modules

Verify the Installation

Once the installation is successful, (RefLink[FindExternalEvaluators, paclet:ref/FindExternalEvaluators]) should discover the installation automatically:

FindExternalEvaluators["NodeJS"]

Possible Issues

If you have installed Node.js according to the preceding steps, but it is not discovered by (RefLink[FindExternalEvaluators, paclet:ref/FindExternalEvaluators]), you can register it manually—with (RefLink[RegisterExternalEvaluator, paclet:ref/RegisterExternalEvaluator]), for example:

RegisterExternalEvaluator["NodeJS","/usr/local/bin/node"]