DEV Community

Hari Krishnan
Hari Krishnan

Posted on

FSD 1.1.1 - Setting up Node

Installing Node Js

Our application development is with React and Node, so both relies on node. In this step we will setup node in our machine

Steps to set up Node.js Using NVM (Node Version Manager)

We are using NVM to setup node because setting up only node from its official website allows you to setup specific versions of node, whereas when we use NVM it allows to switch between node versions locally and manage different versions of node in the system.

STEP 1 : Install NVM:

  1. Open your terminal.
  2. For macOS or Linux, run the following command to download and install NVM:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.5/install.sh | bash
Enter fullscreen mode Exit fullscreen mode

Restart your terminal to apply the changes. Alternatively, you can load NVM manually by running:

For bash users:

source ~/.bashrc
Enter fullscreen mode Exit fullscreen mode

For zsh users (on macOS, it's usually zsh):

source ~/.zshrc
Enter fullscreen mode Exit fullscreen mode

This will load the NVM environment variables.

Verify NVM installation by running:

nvm --version
Enter fullscreen mode Exit fullscreen mode

STEP 2 : Install Node.js Version 18

You can install the latest version as well.

Install Node.js version 18 using NVM:

nvm install 18
Enter fullscreen mode Exit fullscreen mode

This will download and install the latest stable Node.js version 18.x.x.

Set Node.js version 18 as the default version (optional, but recommended):

nvm alias default 18
Enter fullscreen mode Exit fullscreen mode

This ensures that Node.js 18 will be the default version used in new terminal sessions.

Verify the Node.js version by running:

node --version
Enter fullscreen mode Exit fullscreen mode

This should output something like v18.x.x, confirming that Node.js version 18 is installed.

Verify the NPM version (optional):

Since NPM comes bundled with Node.js, check the NPM version:

npm --version
Enter fullscreen mode Exit fullscreen mode

This should output the version of NPM installed along with Node.js.

STEP 3 : Managing Node.js Versions (Optional)

NVM allows you to easily manage and switch between multiple versions of Node.js:

To switch to a different version (e.g., version 14):

nvm use 21
Enter fullscreen mode Exit fullscreen mode

To list all installed Node.js versions:

nvm ls
Enter fullscreen mode Exit fullscreen mode

To install a specific version (e.g., version 16):

nvm install 16
Enter fullscreen mode Exit fullscreen mode

Summary

  1. Install NVM using the curl or wget script.
  2. Install Node.js version 18 with nvm install 18.
  3. Set Node.js version 18 as the default with nvm alias default 18.
  4. Verify the installation with node --version and npm --version.
  5. Optionally, manage multiple Node.js versions using NVM.

This process is identical for both macOS and Ubuntu.

Top comments (0)