npm is the default package manager for Node.js that helps developers to share and reuse their code.
Install Node.js and npm from the Ubuntu repositories
You can install Node.js and npm from the standard Ubuntu repositories. We will use
apt command to install the stable default Node.js version from the Ubuntu repository:
sudo apt update
sudo apt install nodejs
Verify the node.js version, type:
NPM doesn’t ships with Node so you’ll need to separately install it. Run the following command:
sudo apt-get install npm
After finishing the installation, check
Installing Node.js Using NVM
NVM (Node Version Manager) is a bash script that provides facility to manage multiple Node.js versions. You can also use NVM for installing Node.js on your Ubuntu system. Perform the following steps to install any Node.js version on your system.
Open a terminal and install NVM manager using either curl or wget:
curl https://raw.githubusercontent.com/creationix/nvm/master/install.sh | bash
The installation script clones the
nvm repository from Github to the ~/.nvm directory and adds the nvm path to your Bash or ZSH profile.
Once installation complete, you need to update the nvm environemt in current shell using below command:
Now, NVM is successfully installed on your system. Now you can choose specific version of node.js and install with NVM.
To list all available Node.js versions, type:
... v12.13.0 (LTS: Erbium) v12.13.1 (Latest LTS: Erbium) v13.0.0 v13.0.1 v13.1.0 -> v13.2.0
Choose specific version and execute the following command to install, here we will install
nvm install 13.2.0
Verify installation by checking it’s version:
It should show as below:
If you want to uninstall Node.js and npm packages, use the following command:
sudo apt remove nodejs npm
In this tutorial we have shown you two methods to install Node.js on Ubuntu 20.04 Focal Fossa system.
Now that you’ve installed Node.js on your Ubuntu 20.04 system, it’s time to deploy your application.
If you have any questions or feedback, feel free to comment below.
Leave a Reply