DEV Community

Harshavardhan
Harshavardhan

Posted on • Edited on

Installing Node.JS in Mac

According to nodejs.org,

  • Node.js is a JavaScript runtime built on Chrome's V8 JavaScript engine. 🤯

Let me simplify this definition for you.

So, What is a runtime?

You can think of the runtime as an environment that can run javascript code and also does have some extra functionality.

And, what's a JavaScript Engine? 🤔

According to Wikipedia, a JavaScript engine is a computer program that executes JavaScript Code.

  • V8 from Google is the most used JavaScript engine.
  • SpiderMonkey was developed by Mozilla.
  • Chakra is the engine of the Internet Explorer browser

Installing Node.JS

The node team always gives us two main versions of node runtime :

  • LTS ( Long Term Support ): Stability and Code won't break ( No bugs )

💡 Use LTS if you're working on some app and want to deploy it within a few weeks.

  • Current ( Latest Features ): No stability

💡 Use the Current version if you're working on an app that will take at least a year to complete and push to production.

You can find the scheduled releases here for node : https://nodejs.org/en/about/releases/

The simplest way to install Node.JS is to download the LTS or Current Version installer for your operating system.

Download the installer from https://nodejs.org/en/download/ and then open it.

You'll get something like this :
Alt Text

  • Click on continue
  • Agree to the license and follow the steps.

To check whether node.js is installed :
After the installation is completed, Open Terminal App in your Mac and type :

node --version or node -v.

These commands will return the version of node.js installed in your mac.

Alt Text


You can also install node.js via package managers like nvm.

nvm stands for node version manager and is used to have multiple versions of node installed at the same time and it allows us to install, uninstall, switch version, etc.

To install node.js via nvm, we should first install nvm in our mac.

Installing nvm(node version manager):

Copy the install script from https://github.com/nvm-sh/nvm#installation-and-update and paste it in the terminal.

Close and reopen the terminal after nvm is successfully installed.

Enter command -v nvm in terminal. If you see nothing listed, then this means nvm is not loaded into the shell. To fix this:

  1. Check if we have a ~/.bash_profile file.

  2. If we have the file then open it in the nano text editor with the command nano ~/.bash_profile.
    Otherwise, create the file with the command touch ~/.bash_profile and open it.

  3. Add source ~/.bashrc at the bottom of the ~/.bash_profile file. Save and close the editor.

  4. Type source ~/.bash_profile in the terminal. This will re-run the bash profile

  • Now after nvm is successfully installed and loaded. We can install the node now.

  • Open https://nodejs.org/en/ and figure out the node version you want to install.

  • Now, type nvm install <version> to install the node version.

For example, if you want to install, node version 14.15.1. Run nvm install 14.15.1 in the terminal.

  • nvm install node will install the latest node version.
  • nvm use <version> - to use a specific node version.

Top comments (0)