Using apt (older version)#
Install Node.js and npm via apt
sudo apt updatesudo apt install nodejs npm
Using NodeSource (current version)#
Install Node.js via nvm
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bashsudo apt install -y nodejs
Installation notes:
- The apt method installs from Ubuntu's default repositories but may provide older versions
- Using nvm (Node Version Manager) is recommended as it allows:
- Installing multiple Node.js versions
- Easily switching between versions
- Installing the latest releases
- After installing nvm, you may need to restart your terminal or run:
source ~/.bashrc