You've successfully subscribed to developer.school
Great! Next, complete checkout for full access to developer.school
Welcome back! You've successfully signed in.
Success! Your account is fully activated, you now have access to all content.
Success! Your billing info is updated.
Billing info update failed.

Run Multiple Node Versions with NVM

Lately I've been working on some projects that aren't compatible with the latest Node version (8.x), so I figured I'd document the `nvm` tool that I've been using to switch between versions.

Paul Halliday
Paul Halliday

Lately I've been working on some projects that aren't compatible with the latest Node version (8.x), so I figured I'd document the nvm tool that I've been using to switch between versions.

nvm allows us to have (and use) multiple versions of Node on the same machine and we can switch the version with ease. Let's install nvm:

Installation

We can install via cURL by running the following in our terminal:

curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.2/install.sh | bash

Switching Versions

To use nvm, I first check the version number of my current Node installation with node -v, this comes back as 8.4.0, as expected. As I'm looking to work with the Ghost CLI, I'll need to change this to 6.5.0:

To install Node v 6.5.0 we can run:

nvm install 6.5.0

This then automatically switches our version of Node to 6.5.0, allowing us to perform any actions that require this version of Node. Another way to do this is by using nvm use <version-number>, and finding those version numbers is as simple as nvm ls-remote.

We can therefore switch between installed versions with the above.

Restoring PATH

If you no longer need to use nvm or specific versions of Node, you can restore the PATH with nvm deactivate.

JavaScript

Paul Halliday

👋 Want to see more content? Head over to the YouTube channel: https://youtube.com/c/paulhalliday!