Code Self Study Forum

[Tutorial] How to Install Node.js on Linux, Mac, and Windows

I’m going to reference installing Node.js from a few tutorials, so I’ll put the installation instructions here. If other people have tips on installing Node, leave a comment below.

Step 1: See if Node is already installed

Open a terminal window and type this (not including the dollar sign, which just represents the terminal prompty):

$ node -v

If it shows a version number, you already have Node.js installed.

Step 2: Install Node.js

If you don’t have Node installed, use one of the methods below. If you install Node with nvm (Node Version Manager), you can easily run multiple versions of node on the same computer.

How to Install Node.js on Linux or Mac

Go to the nvm page on Github and read the installation section of the instructions. At the time of this forum post, it involves copying a command into your terminal.

After nvm is installed, install a version of node with this command:

$ nvm install 14

That will install Node version 14, which is the current version at the time of writing this. If you prefer a different version of node, just change the number in the command. To see the current versions of node, see this page. The even numbered versions are more stable.

Additional Tips

You don’t need to do anything else, but if you want to know a little more about nvm here are a few tips.

After the nvm command finishes, you will have several new commands available on your computer: node, npm, and npx.

If you want to install a different version of Node, you can type:

$ nvm install 12

To see which versions of Node you have installed, use the nvm list command like this:

$ nvm list
       v12.13.1
        v14.0.0

To switch between them, use the nvm use command:

$ nvm use 12

or

$ nvm use 14

To set one or the other as the default (for example, 14), you can do this:

$ nvm alias default 14

For more details on how to use nvm check out the docs.

How to Install Node.js on Windows

For Windows you can use nvm-windows, which is a version of nvm for Windows.

If you see errors or encounter problems, leave a comment below. :slight_smile:

2 Likes