The easiest way to install Node is to head over to NodeJS’s website and download the LTS version.
The LTS Version is good enough for most users. I use LTS myself.
The Current version is the latest available version. Developers will be making changes and creating libraries on this version. If you use Current, be prepared to run into bugs.
Once you downloaded and installed Node, you should be able to use the node command and the npm command. You can add -v to each of these commands to see their respective versions.
node -vnpm -v
Upgrading and Downgrading Node with a Package Manager
You want to have the flexibility to upgrade and downgrade Node easily.
The simplest way to do this is to use a package called n.
You can install n with npm (Node’s built-in package manager) with the following command:
sudo npm install n -gThe -g flag here stands for global. It lets you use the n command everywhere.
Once you have installed n, you can use the following commands to install different versions of Node.
sudo n lts— installs the LTS versionsudo n latest— installs the latest versionsudo n install <num>— Installs a specific version on Node. Here, you only need to provide the first number. (You can simply write16to get the latest version of16.xx.yy).
Node’s version numbers are written with a standard called Semantic Versioning (Semver). You can find out more about Semver in this article.
Using other package managers
You’re not limited to using n to upgrade or downgrade Node. There are other package managers available and you can choose the one you like.
Welcome! Unfortunately, you don’t have access to this lesson. To get access, please purchase the course or enroll in Magical Dev School.
Unlock this lesson