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:
- Open your terminal.
- 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
Restart your terminal to apply the changes. Alternatively, you can load NVM manually by running:
For bash users:
source ~/.bashrc
For zsh users (on macOS, it's usually zsh):
source ~/.zshrc
This will load the NVM environment variables.
Verify NVM installation by running:
nvm --version
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
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
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
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
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
To list all installed Node.js versions:
nvm ls
To install a specific version (e.g., version 16):
nvm install 16
Summary
- Install NVM using the curl or wget script.
- Install Node.js version 18 with nvm install 18.
- Set Node.js version 18 as the default with nvm alias default 18.
- Verify the installation with node --version and npm --version.
- Optionally, manage multiple Node.js versions using NVM.
This process is identical for both macOS and Ubuntu.
Top comments (0)