3
$\begingroup$

I am setting up NodeJS for use as an external evaluator in Mathematica 13.1 and am getting a message about missing dependencies.

I am following the steps in the Workflow documented at workflow/ConfigureNodeJSForExternalEvaluate in the Mathematica Help System.

After a successful installation of NodeJS and ZeroMQ, I am getting the following message on Step 3 "Verify the installation".

enter image description here

  • In similar posts, this appears to have been solved by issuing a RegisterExternalEvaluator command on "NodeJS".

  • When I issue the following command:

    RegisterExternalEvaluator["NodeJS", "C:\\Program \ Files\\nodejs\\node.exe"]

    I get the following error:

enter image description here

I believe there may be a PATH that needs to be added to Mathematica. However, I am not sure what the PATH should be.

  • The ZeroMQ installation is up-to-date.

  • I have tried adding paths to Environment["PATH"] followed by RegisterExternalEvaluator[...]. So far, this does not change the outcome.

  • NodeJS works from Visual Studio Code. I can write, execute, and debug JavaScript without any problems. Again, this probably points to a problem with my PATHS in Mathematica.

I am guessing that the environment path is not correct.

Could someone direct me to any information on the paths that should be added to the environment for ZeroMQ?

$\endgroup$
2
  • $\begingroup$ Anything that you found out? I am having the same issue. $\endgroup$
    – Ben Dev
    Mar 31 at 2:12
  • $\begingroup$ What helped me is to install node js with homebrew, then add to PATH, to your shell profile (my case .zsh). Then with npm install zeromq, after that you can register the evaluator by putting the node path, then find the evaluator and should be all set to go. $\endgroup$
    – Las Des
    Nov 28 at 22:55

1 Answer 1

3
$\begingroup$

I encountered similar problems and I hope the following may help you.

The relevant paclet is ExternalEvaluate_NodeJS, which can be found in:

FileNameJoin@{$InstallationDirectory, "SystemFiles", "Components", "ExternalEvaluate_NodeJS"}

What I encountered is that I have installed the Node.js modules not in $HomeDirectory, and this paclet fails to recognize it in ExternalEvaluateNodeJS.m:

"ProcessEnvironmentFunction" -> Function[Join[GetEnvironment[], {"NODE_PATH" -> FileNameJoin[{$HomeDirectory, "node_modules"}]}]]

Changing the value of "NODE_PATH" fixed my problem, yet modifying system files is not recommended.

A safer way can be found by looking up the paclet ExternalEvaluate.

ExternalEvaluate`RegisterSystem["NodeJS", "NodeJS", <|"ProcessEnvironmentFunction" -> (Join[GetEnvironment[], {"NODE_PATH" -> "your/path/of/node/modules"}] &)|>]
$\endgroup$
1
  • $\begingroup$ Notice that: 1) since this is undocumented, the method can be version-dependent; 2) besides "ProcessEnvironmentFunction", the problem can come from other parameters. $\endgroup$
    – Lacia
    Jul 28 at 10:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.