DEV Community 👩‍💻👨‍💻

Grant
Grant

Posted on

Installing NodeJs on Linux

OK so you've got Linux installed and want to start developing on an Node environment, But when you run the installer via apt for example, you aren't getting the latest version. Well that's because Linux distribution (in my case Ubutunu) package manager doesn't have the latest version.

Step 1 - Getting the latest version:

Download the latest tar file from here.

Step 2 - Finding the file

Open up your terminal of choice and navigate to where you downloaded the tar file. For me this was Downloads

so I'd have written:

cd Downloads
Enter fullscreen mode Exit fullscreen mode

Step 3 - Update System Packages

Make sure your system is using the latest packages before installing new packages

sudo apt update
Enter fullscreen mode Exit fullscreen mode

Step 4 - Install XZ Utilities:

XZ Utils is a set of free software command-line lossless data compressors, including lzma and xz. In essence these are some powerful tools for file / compression manipulation.

sudo apt install xz-utils
Enter fullscreen mode Exit fullscreen mode

Step 5 - "Install" Node JS tar file:

You can either extract the tar file by opening in Linux and clicking the extract button at the top, or you can use the terminal (my preferred method - as gets you more familiar with the terminal).

To extract with the terminal run the following command:

sudo tar -xvf name_of_file
Enter fullscreen mode Exit fullscreen mode

-x: sets the tar command to extracting
-v: sets the output to verbose outputting all the filenames in the tar.
-f is a flag for specifying a filename

Step 6 - Extracted - Now Install to Directory

So now we have the extracted contents, let's move this contents to our installation folder, using the command:

sudo cp -r directory_name/{bin,include,lib,share} /usr/
Enter fullscreen mode Exit fullscreen mode

Explanation:
cp: copy files command
-r: copy all directories / copy a directory
{bin,include,lib,share}: tells the copy command to copy these matching directories

to the /usr/ folder.

Step 7 - Check the node version installed

Run node --version in the terminal, and it'll tell you what version of node you have installed. If this is successful, you should see the version of Node you downloaded in Step 1.

Top comments (0)

🌚 Browsing with dark mode makes you a better developer.

It's a scientific fact.