Installation of Node JS

Installation of node js

1.Before you start - pick the right version

Always choose an LTS (Long Term Support) release for production and learning projects.it’s more stable and tested. You can downloadofficial installers and see current LTS/Current releases on the Node.js site.


2.Recommended approach (best for developers)

Use a version manager so you can easily switch Node versions per project.
On macOS / Linux / WSL: use nvm (Node Version Manager).
On Windows (native): use nvm windows (a Windows specific manager) or use WSL2 + nvm for Linux-like experience.
Why version managers? they avoid permission issues and let you test multiple Node versions without uninstalling.


3.Install on macOS

Option A — (Recommended) Install with Homebrew
1.Open Terminal
2.Install Homebrew (if you don’t have it)

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

3.Install Node

brew update

brew install node

4.Verify

node -v

npm -v

Homebrew provides an easy, maintainable install on macOS

Option B — Official macOS installer
  • Download the LTS macOS installer from the official Node.js downloads page and run the .pkg installer.
  • Verify with node -v and npm -v.

4.Install on Windows

Option A — Official installer (quick)
1.Download the Windows .msi installer (choose LTS) from the Node.js download page click here
2.Run the installer and follow the wizard.
3.Open Command Prompt / PowerShell and verify

node -v

npm -v

Official installers are convenient for beginners.

Option B — Use WSL2 (recommended for production parity)
1.Install WSL2 and your preferred Linux distro (Ubuntu is common).
2.Inside WSL, follow the Linux instructions below (nvm recommended).

Microsoft documents setting up Node.js on Windows & WSL2 and recommends version managers for workflows.

Option C — Use nvm-windows (manage multiple versions)
1.Download nvm-setup.exe from the nvm-windows releases page and run it.
2.Use commands like

nvm install lts

nvm use lts

node -v

nvm-windows provides a Windows-flavored version-manager experience.


5.Install on Ubuntu / Debian (Linux)

Option A — (Developer-friendly) Install with nvm (recommended)
1.Install nvm (audit the script before piping if you prefer)

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.5/install.sh | bash

Then reload your shell (or run source ~/.bashrc / source ~/.zshrc).

2.Install the LTS Node version with nvm

nvm install --lts

nvm use --lts

nvm alias default lts/*

3.Verify

node -v

npm -v

nvm is the standard version manager on Unix-like systems

Option B — Using NodeSource apt repository (system install)
1.Download and run the NodeSource setup script for the major you want

curl -fsSL https://deb.nodesource.com/setup_22.x | sudo -E bash -

sudo apt-get install -y nodejs

2.Verify with

node -v

and

npm -v

NodeSource provides convenient binary packages for production servers.


6.Troubleshooting (common errors)

  • command not found: node close and reopen your terminal after install; confirm PATH; if using nvm, ensure you sourced the shell profile.
  • Permission errors installing global packages: switch to nvm or change npm prefix (recommended over sudo). docs.npmjs.com
  • Conflicting installs: uninstall previous Node installs before using nvm or nvm windows (recommended to avoid conflicts).


Post a Comment

0 Comments