'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.
Solution 1:[1]
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
Solution 2:[2]
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 :)
Solution 3:[3]
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.
Solution 4:[4]
I found the answer finally!
if anyone is struggling with .tar.xz files then follow the below steps for installation:
EXTRACT THE FILE (Use either terminal or right-click on the file and click "Extract here", file archive will extract the xxxxxx.tar.xz file and you will get a folder with the same your file name xxxxxx)
Copy the entire folder(xxxxxx folder) to /usr/
- you may need to sudo prefix to copy that folder into /usr/
- command to copy is
#sudo cp -r /path-to-the-folder/xxxxxx(sub_folder_name-1,sub_folder_name-2,....) /usr/
There you go.now the program/software is installed and you can use it using your teminal.
Solution 5:[5]
Steps to download and install node in ubuntu/popos
- Download nodejs from https://nodejs.org/dist/v14.18.0/node-v14.18.0-linux-x64.tar.xz
Use cURL to download the TAR archive from the nodejs.org website:
curl -L -o target/path/to/nodejs.tar.xz \
https://nodejs.org/dist/v14.1xxxxx.tar.xz
- Create the new NodeJS dir and extract TAR archive into it:
sudo mkdir -p /usr/local/lib/nodejs \
&& sudo tar -xJvf node-v14.18.0-linux-x64.tar.xz \
-C /usr/local/lib/nodejs
- open terminal and execute below command
less ~/.profile
(Press q to quit less.)
Or:
gopen ~/.profile
Add below to profile
# Nodejs
VERSION=v14.18.0
DISTRO=linux-x64
export PATH=/usr/local/lib/nodejs/node-v14.18.0-linux-x64/bin:$PATH
Refresh profile . ~/.profile
Test installation using terminal:
node -v
npm version
npx -v
- the expected output is something like:
v14.18.0
{
npm: '6.14.15',
ares: '1.17.2',
brotli: '1.0.9',
cldr: '39.0',
icu: '69.1',
llhttp: '2.1.3',
modules: '83',
napi: '8',
nghttp2: '1.42.0',
node: '14.18.0',
openssl: '1.1.1l',
tz: '2021a',
unicode: '13.0',
uv: '1.42.0',
v8: '8.4.371.23-node.84',
zlib: '1.2.11'
}
6.14.15
Solution 6:[6]
Install the latest version or LTS version
sudo apt install nodejs -y
sudo npm i -g n
sudo n latest
or sudo n lts
if you want to install LTS version
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Siddarth |
Solution 2 | Edgar Olivar |
Solution 3 | Natsu |
Solution 4 | Learn More |
Solution 5 | Benji A. |
Solution 6 | buddemat |