I really recommend you install node and npm using nvm. This is the fastest, cleanest and easiest way to do it.
That way, you install NVM simply doing:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.5/install.sh | bash
To test that nvm was properly installed, close and re-open Terminal and enter nvm. If you get a nvm: command not found message, your OS may not have the necessary .bash_profile file. In Terminal, enter touch ~/.bash_profile and run the above install script again.
And you are now able to install node typing:
nvm install <version>
For example
nvm install 4.2.1
if you just want to install the latest node version, you can just type
nvm install node
In order to access node and npm as sudo (in order to have <1024 ports) you should run
n=$(which node)
n=${n%/bin/node}
chmod -R 755 $n/bin/*
sudo cp -r $n/{bin,lib,share} /usr/local
Answer from Luis González on Stack OverflowLinux: Best way to install node & npm
What is the correct way to install Node on a Debian-based Linux OS?
How do I install Node.js????
What's the command to install Node on Ubuntu?
What are the various ways to install Node.js on Linux?
Using a package manager (APT for Ubuntu/Debian, DNF/YUM for RHEL-based distros, Pacman for Arch)
Using Node Version Manager (NVM) – Best for managing multiple versions
Installing from NodeSource – Provides the latest version of Node.js
Downloading precompiled binaries from the official Node.js website
Building from source – Suitable for advanced users who need a custom build
What is Node.js, and why do I need it for Linux?
Can I install Node.js without root/sudo access?
I really recommend you install node and npm using nvm. This is the fastest, cleanest and easiest way to do it.
That way, you install NVM simply doing:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.5/install.sh | bash
To test that nvm was properly installed, close and re-open Terminal and enter nvm. If you get a nvm: command not found message, your OS may not have the necessary .bash_profile file. In Terminal, enter touch ~/.bash_profile and run the above install script again.
And you are now able to install node typing:
nvm install <version>
For example
nvm install 4.2.1
if you just want to install the latest node version, you can just type
nvm install node
In order to access node and npm as sudo (in order to have <1024 ports) you should run
n=$(which node)
n=${n%/bin/node}
chmod -R 755 $n/bin/*
sudo cp -r $n/{bin,lib,share} /usr/local
I wrote in the terminal the following command lines I hope it is useful for the community.
sudo apt install nodejs
curl -L https://npmjs.org/install.sh | sudo sh
good luck!
Should I dow load the tarball file from the nodejs website and install it manually or should I use the package in the debian package repo?
How would one install the tarball version and update nodejs and npm to a newer version manually?