Skip to main content

How to change Node Versions with NVM

Overview​

KT and KT Dashboard 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
v14.17.3
v14.17.4
v14.18.1
v16.13.0
-> v16.14.0
default -> lts/* (-> v16.14.0)
node -> stable (-> v16.14.0) (default)
stable -> 16.14 (-> v16.14.0) (default)

system is the system default. Additionally, 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 16.14.0
Downloading https://nodejs.org/dist/v16.14.0/node-v16.14.0-linux-x64.tar.xz...
######################################################################## 100.0%
Now using node v16.14.0 (npm v8.3.1)

Using​

Switch Node interpreters with nvm use <version>, where <version> is a locally installed Node interpreter.

$ nvm use 16.14.0
Now using node v16.14.0 (npm v8.3.1)
$ node -v
v16.14.0

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/v16.14.0/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​