Overview
Platforms v6.5+ and beyond support multiple Node versions that may be installed using nvm.
Usage
Listing
nvm is provided automatically. First, to list available node interpreters, execute nvm ls
from the terminal:
$ nvm ls
v4.2.4
v5.5.0
-> system
node -> stable (-> v5.5.0) (default)
stable -> 5.5 (-> v5.5.0) (default)
iojs -> N/A (default)
system is the system default. In additional, both v4.2.4 and v5.5.0 have been installed.
Use nvm ls-remote
to show all remote Node packages available for installation on your account.
Installing
To install a Node interpreter, simply run nvm install <version>
, where <version> is a remotely-available version from nvm ls-remote
$ nvm install v4.5.1
Downloading https://nodejs.org/dist/v5.4.1/node-v5.4.1-linux-x64.tar.xz...
######################################################################## 100.0%
WARNING: checksums are currently disabled for node.js v4.0 and later
Now using node v5.4.1 (npm v3.3.12)
Using
Switch Node interpreters with nvm use <version>
, where <version> is a locally installed Node interpreter.
$ nvm use 5.4.1 Now using node v5.4.1 (npm v3.3.12) $ node -v v5.4.1
nvm alias default <version>
will save the <version> interpreter as your system default next time you login, no further activation required.
Path
Once you have settled on a Node interpreter, the absolute path may be discovered using which:
$ which node ~/.nvm/versions/node/v5.4.1/bin/node
Be sure to expand ~ to your home directory. This location be used with Passenger via PassengerNodejs
to use a different Node, other than the system default, to handle requests.
See also
- nvm documentation (github.org)
- KB: Running Node.js