![You don't know Node - EdgeCoders - Medium](https://miro.medium.com/proxy/1*q9ww_u32hhpMaA-Q_s1ujw.png)
Node.js is an open-source, cross-platform, JavaScript runtime environment that executes JavaScript code outside a web browser. Node.js lets developers use JavaScript to write command-line tools and for server-side scripting—running scripts server-side to produce dynamic web page content before the page is sent to the user’s web browser. In this tutorial, let’s see how Install Nodejs on Ubuntu.
Option 1 — Installing Node Using the Node Version Manager
NVM is the easiest way for Linux and Mac. This piece of software allows you to install and maintain many different independent versions of Node.js, and their associated Node packages, at the same time. see how to Install Nodejs on Ubuntu with the following steps.
$ curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash
This will install the nvm
script to your user account. To use it, you must first source your .bashrc
file:
$ source ~/.bashrc
Install the LTS version by typing the following command:
$ nvm install --lts
Installation is finished, verify it by:
$ node -v
Option 2 — Installing Node Using apt-get
Ubuntu 20.04 contains a version of Node.js in its default repositories that can be used to provide a consistent experience across multiple systems. At the time of writing, the version in the repositories is 10.19. This will not be the latest version, but it should be stable and sufficient for quick experimentation with the language
To install a different version of Node.js, you can use a PPA (personal package archive) maintained by NodeSource. These PPAs have more versions of Node.js available than the official Ubuntu repositories. Node.js v10, v12, v13, and v14 are available. let’s add PPA and install Nodejs.
First, we will install the PPA in order to get access to its packages. From your home directory, use curl
to retrieve the installation script for your preferred version, making sure to replace 12.x
with your preferred version string (if different).
$ curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash - $ sudo apt-get install nodejs
Installation is finished, verify it by:
$ node -v
These are simplest methods of installation of nodejs in Ubuntu.