logo

Just A Dev

article cover image

Install multiple NodeJS versions

article cover image

Chuong DangFebruary 18, 2024

Instruction to install NodeJS for beginner

What is NodeJS?

As a developer, or a QA, you should hear about NodeJS already. If not, you can refer to this document https://nodejs.org/en

In short, NodeJS is a Javascript runtime which is designed to build high performance applications (FE, BE, Mobile apps, DevOps tools, you name it).

Please read this to understand what is a runtime

Actually, this blog is published using NodeJS. The source of this blog will be shared in a seperated article.

Why do you need to read this?

Let's say your team is working on 2 projects:

  1. User service (NodeJS 12 - cannot run using NodeJS 14 because of some constraints)
  2. Stock service (NodeJS 14)

But, your machine only have Node 14, then how can you work with them both?

How to install multiple versions of NodeJS in 1 machine?

At this point, NVM https://github.com/nvm-sh/nvm is really a hero. It can help us to solve this issue easily. Let's begin.

0. Install curl (MacOS only)

Install Homebrew (to manage packages)

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

Install curl

brew install curl

1. Install NVM

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

2. Install the Node version you want

nvm install 12 nvm install 14 nvm install 16

3. Use a Node version before working on a project

For example you're going to use version 14

nvm use 14

4. Check your node version

nvm version

If the result is v14.x.x then congratulation! IMG_7951.JPG