How to install Node.js?
Created Jan 22, 2024Last modified Jan 22, 2024
JavaScript Basics
- [1] How to install Node.js?Jan 22, 2024
- [2] What is package.json in Node.js?Jan 22, 2024
macOS
Using Homebrew
Run the following command:
brew install node
Using NVM(Node Version Manager):
- Install NVM by running this command:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
# Or wget
wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
- Restart your terminal and install Node.js using NVM:
nvm install node
Linux (Ubuntu/Debian-based):
Using Package Manager:
sudo apt update
sudo apt install nodejs npm
Using NVM(Node Version Manager):
Same as in macOS part.
Windows
Using Node.js Installer:
- Download the Windows installer from the official Node.js website: Node.js Download
- Run the installer and follow the on-screen instructions.
Using Chocolatey (Package Manager for Windows):
- Open PowerShell as Administrator.
- [Optional] Run the following command to install Chocolatey (if not already installed):
Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
- Install Node.js using Chocolatey:
choco install nodejs
After the installation, you can verify that Node.js is installed by running the following commands in the terminal or command prompt:
node -v
npm -v