Skip to main content

The PreTeXt Guide

Section F.1 Node and npm

To run a Javascript program outside a web browser requires a program that can interpret the Javascript language. A popular choice is node.js, whose executable is simply node. Programs designed for execution by node often build on other programs. These are all organized in packages, which can be managed by the Node Package Manager, known as npm for short. A basic purpose of npm is to manage versions and dependencies among packages.
So the first step is to install both node and npm on your system. These programs are meant to be cross-platform, so once you do these two operating-system-specific installations, we can proceed with generic instructions. (2020-11-09: we could add instructions for specific operating systems to other appendices?)
Now node should be on your path, and you can try
which node
to see if your operating system can locate it automatically. If not, then you will need to edit your peronal copy of the pretext.cfg configuration file to have the node key provide a path to the executable (see Section 47.6).
Some useful npm commands, in the form of examples.
Table F.1.1. Useful npm commands
npm list Full tree of installed packages (local)
npm list mathjax-full Just one package
npm view speech-rule-engine version Available version