Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to install node.tar.xz file in linux

I recently downloaded the Nodejs file from the official site and I don't know how to install the Nodejs from a archived file.

Please help me how can I install this file so that I can run the "npm" command from the CLI for installation of several packages for my own project.

like image 361
Learn More Avatar asked Aug 08 '20 06:08

Learn More


3 Answers

Steps to download and install node in ubuntu

Step 1: Download latest or recommended node .tar.xz file from https://nodejs.org/en/

or you can download node version 14.15.5 (.tar.xz file) directly from here ->

https://nodejs.org/dist/v14.15.5/node-v14.15.5-linux-x64.tar.xz

Step 2: Go to the directory in which (.tar.xz file) is downloaded.

In my case --> /Download directory

Step 3: Update System Repositories

sudo apt update

Step 4: Install the package xz-utils

sudo apt install xz-utils

Step 5: To Extract the .tar.xz file

sudo tar -xvf name_of_file

In my case --> sudo tar -xvf node-v14.15.5-linux-x64.tar.xz

Step 6: sudo cp -r directory_name/{bin,include,lib,share} /usr/

In my case --> sudo cp -r node-v14.15.5-linux-x64/{bin,include,lib,share} /usr/

Step 7: Update the Path export PATH=/usr/node_directory_name/bin:$PATH
In my case --> export PATH=/usr/node-v14.15.5-linux-x64/bin:$PATH

Step 8: Check the node version

node --version

Result In my case -> v14.15.5

like image 83
Azam Baig Avatar answered Nov 13 '22 21:11

Azam Baig


i am new using linux, i use elementary for my old pc, so, i use

sudo apt install nodejs

and then

sudo apt install npm

but was a old version of node and npm so...npm cache clean -f and then npm install -g n

so the last thing i use sudo n stable and is all node v14 installed :)

like image 32
Edgar Olivar Avatar answered Nov 13 '22 21:11

Edgar Olivar


I got it install with below command.

sudo tar --strip-components 1 -xvf {{download-directory}}/{{filename}}.tar.xz --directory /usr/local/

You have to change the download directory and filename according to your preference.

like image 7
Natsu Avatar answered Nov 13 '22 21:11

Natsu