1. Startseite
  2. Node
  3. Changing Node Versions

Changing Node Versions

Übersicht

Platforms v6.5+ and beyond support multiple Node versions that may be installed using nvm.

Verwendung

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 Passagier via PassengerNodejs to use a different Node, other than the system default, to handle requests.

Siehe auch

Aktualisiert am März 7, 2021

Verwandte Artikel