
Node.js is an opensource cross-platform JavaScript runtime environment that executes JavaScript code outside of a web browser. It’s used for building server side applications and command line tools using JavaScript. In this guide given two ways to install Node.js and the NVM on Ubuntu 20.04 LTS Focal Fossa.
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:
node --version
v10.15.2
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 npm
version:
npm -v
v5.8.0
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:
source ~/.profile
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:
nvm ls-remote
... 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 v13.2.0
:
nvm install 13.2.0
Verify installation by checking it’s version:
node -v
It should show as below:
v13.2.0
Uninstalling Node.js
If you want to uninstall Node.js and npm packages, use the following command:
sudo apt remove nodejs npm
Conclusion
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