How to install nodejs ubuntu
How to install nodejs ubuntu
How to Install Latest Node.js on Ubuntu
If you’ve been exploring the world of front-end and JavaScript, you might have come across Node.js. It is a server-side framework that uses Google’s V8 engine to execute JavaScript code. Developers can use Node.js as it provides them with an easy way to build fast and scalable network applications, using single-threaded asynchronous events.
In this article, we will see how to install Node.js on Ubuntu and its derivatives via a new official PPA repository. If you are new to Ubuntu or any other Linux operating system, then be sure to check out our beginner’s guide first.
You can also use the popular Node Version Manager (NVM) for installing specific Node.js version on your system.
Step 1 – Configuring Node.Js PPA
Node.js releases are available in two types, one is the LTS release, and the other is the current release. Choose any one version of your choice or as per the project requirements. Let’s add the PPA to your system to install Nodejs on Ubuntu.
For this tutorial, I am using the latest current release and added their PPA to my system.
Step 2 – Install Node.js on Ubuntu
You have successfully configured Node.js PPA in your Ubuntu system. Now execute the below command to install Node on and Ubuntu using apt-get. This will also install NPM with node.js. This command also installs many other dependent packages on your system.
That’s it. This will install Node.js on your Ubuntu system.
Step 3 – Check Node.js and NPM Version
After installing node.js verify and check the installed version. You can find more details about current version on node.js official website.
Also, check the npm version
Step 4 – Create Demo Web Server (Optional)
This is an optional step. Suppose you want to test your node.js install. Let’s create a web server with “Hello World!” text. Create a file server.js
and add the following content
Save the file and close. Then start the Node application using the following command.
You can also start the application with debugging enabled with the following commands.
How to install nodejs ubuntu
NodeSource Node.js Binary Distributions
If you are looking for NodeSource’s low-impact Node.js performance monitoring platform, please get started here.
Please file an issue if you are experiencing a problem or would like to discuss something related to the distributions.
Pull requests are encouraged if you have changes you believe would improve the setup process or increase compatibility across Linux distributions.
Table of Contents
Debian and Ubuntu based distributions
Available architectures:
NodeSource will continue to maintain the following architectures and may add additional ones in the future.
Supported Ubuntu versions:
NodeSource will maintain Ubuntu distributions in active support by Canonical, including LTS and the intermediate releases.
Supported Debian versions:
NodeSource will maintain support for stable, testing and unstable releases of Debian, due to the long release cycle a considerable number of users are running unstable and testing.
Supported Linux Mint versions:
Supported Devuan versions:
Supported elementary OS versions:
Supported Trisquel versions:
Supported BOSS versions:
Supported BunsenLabs versions:
Supported MX Linux versions:
Supported Sparky Linux versions:
Supported PureOS Linux versions:
Supported Astra Linux CE versions:
Supported Ubilinux versions:
Installation of Node.js on Linux
Node.js is a JavaScript runtime built on Chrome’s V8 JavaScript engine. Node.js can be installed in multiple ways on your Ubuntu Linux machine. You can use Ubuntu’s official repository to install Node.js or another way to use NodeSource repository. Installation via NodeSource repository will allow you to choose latest version of Node.js.
Installing Node On Ubuntu 18.04 and 16.04: There are two methods Ubuntu official repository and NodeSouce repository to install Node.js on Ubuntu.
Install Node.js using Ubuntu official repository: Node.js is available in Ubuntu’s repository and you can easily install it using a few commands. Follow the steps below to install Node.js on your Ubuntu operating system.
sudo apt install nodejs
Note: It is recommended to install Node Package Manager(NPM) with Node.js. NPM is an open source library of Node.js packages.
To install NPM, use the following commands:
Node and NPM will be successfully installed on your Ubuntu machine.
Install Node.js using NodeSouce repository: The latest version of Node.js can be installed from NodeSource repository. Follow the steps below to install the Node.js on your Ubuntu.
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install python-software-properties
sudo apt-get install nodejs
The NodeSource Blog
You have reached the beginning of time!
All Posts
How To
Installing Node.js Tutorial: Ubuntu
Tierney Cyren
in How To on Dec 08 2016
Installing Node.js is always going to be the first step to getting up and running with building applications with Node.js.
In this tutorial, I’m going to show you how to get Node.js installed quickly on Ubuntu. Once completed, you’ll have Node.js installed and be ready to start building!
This guide covers installing Node on both the Ubutntu Desktop and Ubuntu Server distributions of Ubuntu, for any of the following versions: Precise Pangolin (12.04), Trusty Tahr (14.04), Xenial Xerus (16.04), Yakkety Yak (16.10)
If you just want to get Node.js installed on Ubuntu (specifically the Precise, Trusty, or Xenial distributions), and don’t need anything else other than the quick how, here are the two commands you need to run.
To install Node.js on Ubuntu, you will need to ensure that your system meets following requirements:
Your environment is on a supported architecture:
Your environment is using a supported Ubuntu LTS distribution:
The first part of downloading the correct Node.js binary is to add the APT repository for Node.js Debian-based and add the associated PGP key to the APT keychain.
To set up the current APT repository and add the PGP key to the system’s APT keychain, you need to run this command:
Step 3: Running apt-get to Install Node.js
Once this install is run to completion, should have been successfully installed on the system!
Step 4: Confirm Node.js was Successfully Installed
To confirm that Node.js was successfully installed on your system, you can run the following command:
If Node is installed, this command should print out something close to (but probably not exactly) this:
Step 5: Finally, Update Your Version of npm
To get the most up-to-date npm, you can run the command:
How to Install Node.js and npm on Ubuntu Linux
If you are looking to install Node.js on Ubuntu Linux, you’re in luck. Node.js is available in the Ubuntu repository and you can easily install it with a few commands.
Node.js is supported by npm (Node.js Package Manager). It’s an open-source library of Node.js packages. So you can use one in your application without needing to rewrite the entire thing all on your own.
There are two main ways you can install Node.js and npm on Ubuntu:
Method 1: Install Node.js and npm on Ubuntu using the official repository
As I said earlier, Node.js is available on Ubuntu. So all you need to do is to open a terminal and use the following command:
To install npm, use the following command:
I recommend installing npm as well because you’re going to need it anyway. Both Node.js and npm are quite small.
For working on Node.js, you can use any good code editor for Linux or an IDE. It’s basically your preference.
I’m not going to show you how to get started with Node.js because that’s not the purpose of this quick tutorial.
If you want to remove Node.js and npm, you can use the command below:
Note: If you’re getting a “/ usr /bin/env: node: No such file or directory” error while running the npm command to install a node module, you can easily fix it.
Method 2: Install Node.js and npm on Ubuntu using NodeSource repository
You can install Node.js and npm directly from the NodeSource repository. Node.js provides an easy-to-use bash script for this purpose.
What you have to keep in mind is that you need to specify which major version of Node.js you want to install.
Let’s say you want to install Node.js version 11. First, install Curl on Ubuntu:
Now you can use the following command:
If you want to install Node.js version 10, you can replace setup_11.x with setup_10.x.
The above command will download and start running the installation script. The script will add a new repository in the source list directory (/etc/apt/sources.list.d). It will also add the GPG key of the new repository automatically.
With this new repository added to the sources list, you can install Node.js using the apt command. The added advantage is that the installed Node.js version can be updated easily like a regular package using the sudo apt update && sudo apt upgrade command.
To install the Node.js package, use the following command. Npm is also installed with this package.
Once installed, you verify it by checking the installed version of Node.js with this command:
The output should be like this:
You can also verify the npm installation:
The output should be similar to this:
After that, if you love Node.js, you should check out NodeOS, a Linux distribution for Node.js users.
Creator of It’s FOSS. An ardent Linux user & open source promoter. Huge fan of classic detective mysteries ranging from Agatha Christie and Sherlock Holmes to Detective Columbo & Ellery Queen. Also a movie buff with a soft corner for film noir.