How To Install latest Node.js on Ubuntu
How To Install Node.js on Ubuntu
Node.js is a popular JavaScript runtime built on Chrome's V8 JavaScript engine. It allows developers to run JavaScript on the server side to build scalable network applications. This guide will walk you through the steps to install Node.js on an Ubuntu 20.04 system.
Install Node.js Using NodeSource Repository
For the latest version of Node.js, it's recommended to use the NodeSource repository. First, download and install the NodeSource PPA (Personal Package Archive):
cd ~ curl -sL https://deb.nodesource.com/setup_20.x -o /tmp/nodesource_setup.sh
Refer to the NodeSource documentation for more information on the available versions.
Inspect the contents of the downloaded script with `nano` or your preferred text editor:
nano /tmp/nodesource_setup.sh
When you are satisfied that the script is safe to run, exit your editor. Then run the script with sudo:
sudo bash /tmp/nodesource_setup.sh
The PPA will be added to your configuration and your local package cache will be updated automatically. You can now install the Node.js package in the same way you did in the previous section:
sudo apt install nodejs
Verify that youââ¬â¢ve installed the new version by running Node.js with the `-v` version flag:
node -v
Output:
v16.19.0
Conclusion
You have successfully installed Node.js on your Ubuntu 20.04 system. You can now start developing your Node.js applications. Whether you choose to use the default repository, the NodeSource repository, or `nvm`, you have flexibility in managing your Node.js versions. Happy coding!
This article provides a comprehensive guide to installing Node.js on Ubuntu 20.04, covering different methods and additional tips for managing Node.js versions.