Graphic showing 5 ways to install Node.js
BCiriak Avatar
by BCiriakMAY 07, 2022 | 4 min read

Here are 5 ways to install Node.js in 2022

Node.js is one of the important technologies of modern web development. Every web developer should understand the basics and what Node.js can provide for us. If you do not have Node installed, continue to the tutorial, where we will learn how to install it on your machine.


These are the 5 ways to install Node.js on any machine:

1. Node Website (Mac, Windows, and Linux)

The first way you would probably encounter is the simplest and the most straightforward way. When you visit the Node.js website, you will be shown the download options for your OS right on the homepage.

And the installation process is very simple, download the installer and install Node.js. With this installation you also get NPM installed. NPM is package manager for JavaScript, with which you can install all of the JavaScript modules and libraries shared on the NPM website.

2. Curl (Mac)

A second most common way in my opinion, at least for Mac users is by using the cURL terminal program. If you use the terminal, command line, or any alternative, I am pretty sure you have used cURL before. cURL is an amazing command-line tool for transferring data over various protocols as stated on the official wiki page. Here is what the cURL command for downloading the latest Node.js looks like:

shell
curl "https://nodejs.org/dist/latest/node-\${VERSION:-\$(wget -qO- https://nodejs.org/dist/latest/ | sed -nE 's|.*>node-(.*)\\.pkg</a>.*|\\1|p')}.pkg" > "\$HOME/Downloads/node-latest.pkg" && sudo installer -store -pkg "\$HOME/Downloads/node-latest.pkg" -target "/"

3. Homebrew (Mac)

The third way is by using the brilliant Mac package manager called Homebrew. This was quite frankly my favorite way for some time. You can download and install Homebrew with just mentioned cURL from Homebrew website.

It is really great tool for managing lots of needed tools for development like MySQL, PHP, Node.js, and much more. You can search packages on Homebrew with a simple search command like so: brew search node. And once you find your package, you can install it similarly with the command brew install node. This command would install the latest Node.js version.

4. Chocolatey (Windows)

Very similar to Homebrew, but for Windows users is the Chocolatey package manager. The main requirement here is to have Windows PowerShell so you can use Chocolatey. You can read about the requirements and installation on Chocolatey website. Similarly to Homebrew, once you have Chocolatey installed, you can search and install your packages with these commands choco search nodejs and choco install nodejs.

5. NVM (Mac and Linux)

Last, and my favorite way to install and work with Node.js, is to use NVM, or Node Version Manager. And there are a couple of these version managers like n, nvm, and some more, so you can pick the one that you like. The king that stands out and is basically the standard is the package manager called NVM. You can have a look at it on their official nvm GitHub repo here. It is under active development and support and it works great. Yes, the setup is more “difficult” (not really) than with other install options, but you get lots with it.

Every serious Node.js developer needs to have NVM installed.

The best thing about using Node Version Manager is, that you can use different versions of Node.js on your system without any hustle. You can switch between those versions to work on legacy applications that use older node versions. It’s just amazing. I highly recommend using NVM.

5.1. NVM-WINDOWS (Windows)

There is a Node.js version manager for Windows users also. I haven’t used it, so I’m not gonna write about it, but feel free to check it out on the official nvm-windows GitHub repo.

Yes, there are quite a few more ways to install Node.js on your machine, but these are the ones I have decided to write about. Feel free to comment in your favorite way.

Thank you for taking your time to go through this shortlist and I hope you did learn something new.

Keep learning and see you in the next one!

Connect with me on social media ✨

Join my newsletter, to receive JavaScript, TypeScript, React.js and more news, tips and other goodies right into your mail box 📥. You can unsubscribe at any time.

©2024 JSTopics. All rights reserved.