
You will use this method to manage multiple Node.js versions on a per-user basis. Also, if you are a Node.js developer, you are recommended to choose this way of installation. If you need to have multiple Node.js versions installed on the same machine, this method is what you must use. The third and last way of installing Node.js and Npm is to use Node Version Manager. Use the following command to install the development tools, it allows you to compile native addons from npm: sudo apt install build-essential Install Node.js and Npm using NVM To do this, run: node -version npm -version Then, you can verify if the Node.js and Npm were successfully installed or not.

Note: The Node.js package contains both the node and npm binaries. When the NodeSource repository is enabled, run the command below to install Node.js and Npm: sudo apt install nodejs Note: To change the version of Node.js to another considered one (for example 12x,) you just need to change the setup_14.x with setup_12.x. The script will also create an apt repository file, install all necessary packages, and refresh the apt-cache. In this way, the NodeSource signing key will be added to your system.

So, use the following command to download and execute the NodeSource installation script: curl -sL | sudo -E bash. Here, you will install Node.js version 14.x. At the time of writing, the NodeSource repository provides v14, v13, v12, and v10 versions. If your application requires a specific version of Node.js, use this repository.

NodeSource maintains an APT repository containing multiple Node.js versions. If you want to install a different Node.js version than the one provided in the Ubuntu repositories, you can use this method. Currently, NodeSource supports Node.js v14, v13, v12, and v10. When you are finished, run the command below to verify the installation: nodejs -version Install Node.js and Npm from NodeSource In this way, you will install a number of packages, including the tools necessary to compile and install native addons from Npm. Use the following command to update the package index and install Node.js and N pm: sudo apt update sudo apt install nodejs npm So, you can expect a straightforward installation. This is the first and the easiest way to install Node.js and Npm on Ubuntu 21.04. Install Node.js and Npm from Ubuntu Repositories

_ To seup, follow our Initial server setup on Ubuntu 21.04. To let this tutorial work better, please consider the below Prerequisites: Recommended Article: Tutorial Setup And Configure Nessus On Ubuntu 20.10 Prerequisites to Install Node.js and Npm on Ubuntu 21.04
