To install Node.js on Ubuntu, you can follow these steps:
First, open a terminal window and update the apt package manager:
sudo apt update
Next, install the curl package, which will allow you to download Node.js from the command line:
sudo apt install curl
Once curl is installed, use it to download the Node.js package from the official Node.js website:
curl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash -
If you want to install a different version of Node.js, you can replace setup_14.x
in the curl
command with the version number of the Node.js release you want to install. For example, if you want to install version 12.x, you would use the following command:
curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash -
You can find a list of all available Node.js releases on the official Node.js website, along with their corresponding version numbers. Choose the version you want to install and use the appropriate curl
and apt install
commands to install it on your system.
Finally, install Node.js and npm (the Node.js package manager) using the following command:
sudo apt install nodejs
After running this command, Node.js and npm should be installed on your system. To verify that the installation was successful, you can run the following commands to print the version numbers of Node.js and npm:
node -v
npm -v
You should see output similar to this, indicating that Node.js and npm are installed and working correctly:
v14.9.0
6.14.8