We will be installing nodejs on Ubuntu 1804 using personal package archive (PPA) which is more recent compared to the official Ubuntu repositories.
cd ~
curl -sL https://deb.nodesource.com/setup_10.x -o nodesource_setup.sh
sudo bash nodesource_setup.sh
Now you are ready to install the nodejs
package:
sudo apt install nodejs
After the install completes, you can now check the version of nodejs
package:
nodejs -v
The nodejs
package using the method above also includes npm
so there’s no need to install npm
separately. To verify the version of npm
type:
npm -v