Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

How to Install Node.js on Ubuntu – Node Linux Installation Guide

If you are a web developer working on the frontend or the backend, you'll want to have Node.js installed on your system. But if you use the typical sudo apt install nodejs command, it may install a very old version of Node which can be troublesome for you.So you'll want to install a specific version, which requires a different command. This will install the LTS (Long-Term Support) version of Node which is useful for devs because it has a longer period for support. Today, I am going to show you how you can install the latest LTS version of Node on your Ubuntu operating system. This processes will work on any kind of Debian-based Linux operating system (Ubuntu, Mint, Zorin, Debian, Elementary OS, and so on). It'll work whether you are using that as your main operating system, secondary operating system on dual boot, WSL on Windows, or using in a virtual machine (VMware Workstation, VirtualBox, and so on).I have also created a complete video to show you the process step-by-step. You can watch it here:At the time of writing this article, the latest LTS version for Node is 18.18.2.When you install Node following the instructions in this article, it will install the latest LTS version of Nodejs automatically. So you'll be safe without any hassle if you simply follow this article and the accompanying video.First, you'll want to ensure that you have installed all the updates beforehand. I like to work in the terminal mostly, so I'll install the updates using the terminal directly. For updating to the latest versions of all the relevant packages, use sudo apt update in the terminal. Use your password when it asks for that.Now use sudo apt upgrade -y to upgrade all the upgradable packages.We're using the Node Version Manager (NVM) here to install Node. There are various advantages when we install Node and npm using the NVM as it also allows us to manage multiple versions of Node.js on our system altogether. First, you'll need to install curl if it's not installed on your system already. You can install curl by using the command below:Now you'll need to follow these steps in order to ensure that you've installed Node.js successfully on your system.Install the Node Version Manager (NVM) by using the following command:When you run this specific command, the curl downloads the NVM installation script from that specific URL. Afterward, bash executes the same script for installing NVM.Activate the NVM using the command below:Install the latest Long Term Support version of Node by using the command below:It installs the latest version of the LTS release of Node by default. We have installed the latest LTS version of Node, but we also need to set the default version of NVM so that it gets used by default whenever we need it. You can use the command below to do that. Make sure to change the version to the exact LTS version you have installed on your system just now. If your LTS version is something like 24.1.2 then the command would be like below:Use the command below to check whether the default version is the exact version you just installed:After installing Node and NPM, you need to set up the Node environment by creating a new Node project.Use the command below to create a new directory/folder where you want to test a simple "Hello World" type Node project.Navigate to the my-node-project directory by using the command below:Initialize the new Node project like this:This command will create a "package.json" file containing your project's metadata and dependencies. Here is the JSON output:The JSON output is below:Now run the setup with the simple command. For this, I am going to create a new file called app.js using the nano text editor in the terminal.Once the text editor opens, type the below code:Use Ctrl+ O to save the file. Use Enter to save the file as app.js:Use Ctrl + X to return to the bash terminal again.Now, it is time to check the output and see whether it's working or not.Use the command below:It is working!We have successfully installed the latest LTS release of Node on our Ubuntu/Debian-based Linux operating system.Cheers! 🥂Thank you so much for reading the entire article till now.If you have enjoyed the procedures step-by-step, then don't forget to let me know on Twitter/X or LinkedIn.You can follow me on GitHub as well if you are interested in open source. Make sure to check my website (https://fahimbinamin.com/) as well! If you like to watch programming and technology-related videos, then you can check my YouTube channel, too.All the best for your programming and development journey. 😊You can do it! Don't give up, never! ❤️Microsoft Research Investigation Contributor to OSS (GitHub: FahimFBA) | Software Engineer | Top Contributor 2022, 2023 @freeCodeCamp | ➡️youtube.com/@FahimAmin If you read this far, thank the author to show them you care. Say Thanks Learn to code for free. freeCodeCamp's open source curriculum has helped more than 40,000 people get jobs as developers. Get started freeCodeCamp is a donor-supported tax-exempt 501(c)(3) charity organization (United States Federal Tax Identification Number: 82-0779546)Our mission: to help people learn to code for free. We accomplish this by creating thousands of videos, articles, and interactive coding lessons - all freely available to the public. We also have thousands of freeCodeCamp study groups around the world.Donations to freeCodeCamp go toward our education initiatives, and help pay for servers, services, and staff. You can make a tax-deductible donation here.



This post first appeared on VedVyas Articles, please read the originial post: here

Share the post

How to Install Node.js on Ubuntu – Node Linux Installation Guide

×

Subscribe to Vedvyas Articles

Get updates delivered right to your inbox!

Thank you for your subscription

×