How to install Node.js on Ubuntu from tar.xz? [SOLVED]


Author: Omer Cakmak
Reviewer: Deepak Prasad

Getting started with Node.js Installation

Node.js is an open source (MIT License) runtime environment developed for networked applications that run mainly on the server side. Node.js applications are typically developed using JavaScript, a client-side scripting language. Since it is based on Javascript, it has a very dynamic and fast structure.

In this article, we will explain the steps of how to install node.js from tar.xz to Ubuntu but you wish to use any other method to install Node.js then you can refer Install Node.js on Ubuntu 20.04 [3 Different Methods].

But to learn more you can refer to our in-depth Node.js Tutorial.

Let's start the installation of Node.js from tar.gz on Ubuntu step by step.


Step-1: Downloading Node.js tar.gz File

The recommended version on the Node.js official website is 18.12.1 LTS. Go to its official address, right click on the download link and copy the link.

install nodejs


19.1.0 is available in the latest version at the same address. You can also download and install a different version.

foc@ubuntu22:~$ wget
--2022-11-27 19:08:00--
Resolving (,, 2606:4700:10::6814:162e, ...
Connecting to (||:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 23726988 (23M) [application/x-xz]
Saving to: ‘node-v18.12.1-linux-x64.tar.xz’

node-v18.12.1-lin 100%[=============>]  22.63M  1.85MB/s    in 11s     

2022-11-27 19:08:12 (2.10 MB/s) - ‘node-v18.12.1-linux-x64.tar.xz’ saved [23726988/23726988]


Step-2: Unzip the Compressed File

Unzip the tar.gz file to your current directory:

foc@ubuntu22:~$ tar xvfJ node-v18.12.1-linux-x64.tar.xz 


Step-3: Installing Node.js on the System

Copy the libraries and executables under the /usr directory. In this way, you can access node.js packages without changing the PATH:

foc@ubuntu22:~$ sudo cp -r node-v18.12.1-linux-x64/{bin,include,lib,share}  /usr/

The files are placed in the relevant directories:

foc@ubuntu22:~$ find /usr -name node


Step-4: Check Version

Invoke the node command from the terminal:

foc@ubuntu22:~$ node 
Welcome to Node.js v18.12.1.
Type ".help" for more information.


foc@ubuntu22:~$ node --version


Bonus Tip: Create and test a web server!

One of the biggest features that distinguishes Node.js from other languages is that it can create a web server with just a few lines of code.

Create example_server.js file:

foc@ubuntu22:~$ touch example_server.js

Open the file and type the following lines:

foc@ubuntu22:~$ nano example_server.js

var http = require('http');

http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Hello World!');

Then run the generated file:

foc@ubuntu22:~$ nohup node example_server.js > node.log 2>&1 &

Now make a request to port 8080:

foc@ubuntu22:~$ wget -q -O -
Hello World!foc@ubuntu22:~$

Great, the server worked!



In this article, we explained how to install Node.js from the tar.gz file. To get help with installed Node.js, run the following command in terminal:

foc@ubuntu22:~$ node --help
Usage: node [options] [ script.js ] [arguments]
node inspect [options] [ script.js | host:port ] [arguments]

- script read from stdin (default if no
file name is provided, interactive mode
if a tty)
-- indicate the end of node options

or you can get support from the manual page:

foc@ubuntu22:~$ man node

node — server-side JavaScript runtime

node [options] [v8-options] [-e string | script.js | -] [--]
[arguments ...]
node inspect [-e string | script.js | - | <host>:<port>] ...
node [--v8-options]

Node.js is a set of libraries for JavaScript which allows it to
be used outside of the browser. It is primarily focused on cre‐
ating simple, easy-to-build network clients and servers.


References - How to install node.tar.xz file in linux
man page for node


Views: 544
Omer Cakmak

Omer Cakmak

He is highly skilled at managing Debian, Ubuntu, CentOS, Oracle Linux, and Red Hat servers. Proficient in bash scripting, Ansible, and AWX central server management, he handles server operations on OpenStack, KVM, Proxmox, and VMware. You can connect with him on his LinkedIn profile.

Can't find what you're searching for? Let us assist you.

Enter your query below, and we'll provide instant results tailored to your needs.

If my articles on GoLinuxCloud has helped you, kindly consider buying me a coffee as a token of appreciation.

Buy GoLinuxCloud a Coffee

For any other feedbacks or questions you can send mail to

Thank You for your support!!

2 thoughts on “How to install Node.js on Ubuntu from tar.xz? [SOLVED]”

Leave a Comment