
In order to use npm to build native tools, you require development tools and libraries that you install on Ubuntu 22.04/20.04/18/04 as below: sudo apt -y install gcc g++ make As seen the current version in use is v16.14.1 we now switch to version 16. Set the default version of Node.js with this command. In case you have multiple versions of Node.js installed list them with: $ nvm ls

Once complete, check the installed version of Node.js. # 100.0%Ĭreating default alias: default -> v16 (-> v16.14.2)Īnother example on installation of version 16.14.1: $ nvm install v16.14.1ĭownloading and installing node v16.14.1. Sample Output: Downloading and installing node v16.14.2. Proceed and install the Node.js 16.x version that you want on Ubuntu 22.04/20.04/18/04. nvm list-remoteįrom the above output, nvm has many versions of Node.js. Now with NVM installed, check the available Node.js versions. "$NVM_DIR/bash_completion" # This loads nvm bash_completionįrom the above output, the path of nvm has been added to the current session. => Close and reopen your terminal to start using nvm or run the following to use it now: => Appending bash_completion source string to /root/.bashrc => Appending nvm source string to /root/.bashrc => Downloading nvm as script to '/root/.nvm' Install NVM toolĭownload and install Node Version Manager as below. V16.14.2 Method 2) Install Node.js and npm using NVMįrom NVM(Node Version Manager) you can install Node.js 16 using the following steps. Once installed, verify the version of Node.js. With the repository added successfully, you can now install Node.js 16 on Ubuntu 22.04/20.04/18.04 with the command: sudo apt -y install nodejs

This command creates APT sources list for Nodesource Nodejs 16 repo which can be viewed as below. Install cURL in case you haven’t installed it using sudo apt install curl.

From your home directory, use the cURL command. First, we will need to install the PPA in order to install Node.js 16. These PPAs have a lot more versions of Nodejs as compared to the official Ubuntu repositories. To install any version of Node.js you can use a PPA (personal package archive) which is maintained by Nodesource.
