Installation of NodeJS on Linux
The Nodejs runtime is based on Chrome's V8 JavaScript engine. On your Ubuntu Linux desktop, there are many options to install NodeJS. Nodejs enables JavaScript to be used for server-side scripting and runs scripts server-side to produce dynamic web pages. Another notable thing is Nodejs has a command-line utility called npm, a package manager to install, manage Nodejs libraries and applications. Nodejs package ecosystem is the largest ecosystem of open source libraries in the world. To install NodeJS, you can use Ubuntu's official repository or the NodeSource repository. You will select the new version of NodeJS if you install it from the NodeSource repository.
We'll learn how to get started with NodeJS on an Ubuntu 18.04 server in this tutorial.
Let's dive straight into it.
Prerequisites
- Ubuntu 18.04 Bionic Beaver
- A user with Sudo privileges.
- Access to a terminal/command line
Install NodeJS
To install NodeJS on Ubuntu, you can use either the Ubuntu official repository or the NodeSouce repository.
Install NodeJS using Ubuntu official repository
NodeJS is included in Ubuntu's repositories, and it's simple to update with a few commands.
To install NodeJS use the following command:
sudo apt install nodejs
After it's been installed, run the following command to search the installed version:
node -v or node –version
Installing Node Package Manager (NPM) with NodeJS is highly recommended. To install npm run the following command in your terminal:
sudo apt install npm
npm -v or npm –version
Install NodeJS using NodeSouce repository using a PPA
You will get a more recent version of NodeJS by adding the PPA directly from NodeSource. Unlike the official Ubuntu repository, NodeSource manages up-to-date versions of NodeJS, as stated in the previous section.
Use the following command to install Python program libraries:
sudo apt-get install python-software-properties
Add NodeJS PPA to the system.
curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash –
Using the commands below to install NodeJS and NPM on your Ubuntu machine:
sudo apt-get install nodejs
After it's been installed, run the following command to search the installed version:
node -v or node –version
npm -v or npm –version
Finally, on your Ubuntu computer, you have successfully installed NodeJS and NPM.
Conclusion
Finally, at the end of this tutorial, we've had learned how to install NodeJS and NPM on Linux. As you can see, getting Nodejs up and running is pretty easy. In just a few minutes, everyone can install and configure Nodejs.