How to Install Node.js and NPM On Ubuntu 20.04
In this post we will give you information about How to Install Node.js and NPM On Ubuntu 20.04. Hear we will give you detail about How to Install Node.js and NPM On Ubuntu 20.04 And how to use it also give you demo for it if it is necessary.
In this blog, we will show you three different ways of getting Node.js installed on an Ubuntu 20.04 server:
aptto install nodejs package from Ubuntu’s default software repository.
aptwith an alternate PPA (Personal Package Archive) software repository to install specific versions of the nodejs package.
nvm, the Node Version Manager, and using it to install and manage multiple versions of Node.js.
Option 1: Installing Node.js with Apt from the Default Repositories
The recommended way to install Node.js on your Ubuntu 20.04 LTS is by using the apt command to install the stable default Node.js version from the standard Ubuntu Repository:
sudo apt install nodejs
Once installed, check the node.js version:
In most cases, you’ll also want to also install
npm, the Node.js package manager. You can do this by installing the
npm package with
sudo apt install npm
This will allow you to install modules and packages to use with Node.js.
At this point, you have successfully installed Node.js and
apt and the default Ubuntu software repositories.
Option 2: Installing Node.js with Apt Using a NodeSource PPA
To install a different version of Node.js, you can use a PPA (personal package archive) maintained by NodeSource. NodeSource is a company focused on providing enterprise-grade Node support. It maintains an APT repository containing multiple Node.js versions.
At the time of writing, the NodeSource repository provides the following versions:
- v14.x – The latest stable version.
- v12.x – The latest LTS version.
- v10.x – The previous LTS version.
We’ll install Node.js version 14.x:
Run the next command as a person with sudo privileges to obtain and execute the NodeSource set up script:
curl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash -
As soon as the NodeSource repository is enabled, set up Node.js and npm:
sudo apt install nodejs
Now you can verify Node.js and NPM Version with this command:
node -v npm -v
Also see: Install Apache on Ubuntu 20.04 LTS
Option 3: Installing Node.js and NPM using NVM
NVM is also known as “Node Version Manager” is a script that allows you to manage multiple versions of Node.js.
First, you will need to download and install NVM in your system. You can download and run the script manually with the following command:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash
Do not use
sudo as it will enable
nvm for the root user.
The script will clone the project’s repository from Github to the
=> Appending nvm source string to /root/.bashrc => Appending bash_completion source string to /root/.bashrc => Close and reopen your terminal to start using nvm or run the following to use it now: export NVM_DIR="$HOME/.nvm" [ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm [ -s "$NVM_DIR/bash_completion" ] && . "$NVM_DIR/bash_completion" # This loads nvm bash_completion
Because the output above says, it’s best to both shut and reopen the terminal or run the instructions so as to add the trail to
nvm script to the present shell session. You are able to do no matter is simpler for you.
As soon as the script is in your
PATH, confirm that
nvm was correctly put in by typing:
To get a list of all Node.js versions that can be installed with
The command will print a list of all available Node.js versions. It’s a very long list!
To install the latest available version of Node.js, run:
nvm install node
After Install Node.js, you can check the version of Node.js and NPM using this command:
node -v npm -v
Let’s install two more versions, the latest LTS version, and version
nvm install --lts nvm install 10.9.0
If you want to change the currently active version, enter:
nvm use 15.9.0
After running this command, you can see now we use node
Thank you for reading this article!!
Also see: Install Nginx on Ubuntu 20.04 LTS
Hope this code and post will helped you for implement How to Install Node.js and NPM On Ubuntu 20.04. if you need any help or any feedback give it in comment section or you have good idea about this post you can give it comment section. Your comment will help us for help you more and improve us. we will give you this type of more interesting post in featured also so, For more interesting post and code Keep reading our blogs