How to download, unzip and install a specific version of Node.js on Linux

How to download, unzip and install a specific version of Node.js on Linux

In this article, we will detail the steps to install Node.js LTS in Linux systems. We'll explain step-by-step how to download, unzip, and configure Node.js to ensure you have a smooth installation process. From using the wget command to get the correct files to unpacking the files via the tar command to adding Node.js to your system path to run commands from anywhere, we'll guide you through the entire process. Additionally, we provide the option to update npm to ensure you are using the latest Node.js package manager. By following this guide, you will easily master the tips and methods of installing Node.js LTS on your Linux system. Whether you are a newbie or an experienced developer, this article will provide you with clear guidance to help you successfully integrate Node.js into your projects.

This article provides detailed steps for downloading, unzipping, and installing a specific version of Node.js. Take downloading the node-v18.17.1-linux-x64.tar.xz file as an example. The following is the installation process:

Open Nodejs official website

https://nodejs.org/en/download
linux nodejs
You can see that the latest LTS long-term support version is 18.17.1 and includes npm 9.6.7 version. We right-click to select Linux Binaries(x64)the option and copy the download link, and use the wget command in Linux to download the compressed package.

download file:

First, use the wget command in the terminal to download the Node.js compressed package file:

wget https://nodejs.org/dist/v18.17.1/node-v18.17.1-linux-x64.tar.xz

To unzip and install node-v18.17.1-linux-x64.tar.xzNode.js from the file, you can follow the steps below. Please note that file names and version numbers may change over time, so make sure to use the correct file names and version numbers.

unzip files:

Unzip the .tar.xz file using the following command:

tar -xvf node-v18.17.1-linux-x64.tar.xz

Enter the directory:

Enter the unzipped directory:

cd node-v18.17.1-linux-x64

Copy to the installation directory:

Copy the unzipped files to the directory where you want to install Node.js. Typically, files can be copied to /usr/localthe directory, which is a common installation path. Use the following command:

sudo cp -R * /usr/local/

Set environment variables:

Add the Node.js executable path to your system PATH so you can run Node.js commands from anywhere.

Execute the following command in the terminal to edit your shell configuration file (such as .bashrc, .zshrcetc.):

nano ~/.bashrc

Add the following lines at the end of the file:

export PATH=$PATH:/usr/local/bin

Save the file and exit the editor, then make the configuration effective:

source ~/.bashrc

Verify installation:

Run the following command in the terminal to verify that Node.js is installed correctly:

node -v

You should see the output showing the installed Node.js version number (v18.17.1 in this case).

Update npm (optional):

During the installation of Node.js, npm (Node.js package manager) is also installed. You can use the following command to update npm to the latest version:

npm install -g npm

Now, you have successfully unzipped and installed it Node.js v18.17.1. Remember to make appropriate adjustments based on the actual file name and version number.

In this article, we dive into the detailed steps to install Node.js v18.17.1 in Linux systems. From downloading the compressed package to unzipping the file to integrating Node.js into the system path, we provide step-by-step guides designed to help developers of all types complete the installation easily. By updating npm, you can also ensure that you are using the latest Node.js package manager. No matter your technical level, this article provides you with a reliable method to help you successfully install and utilize Node.js v18.17.1 on your Linux system, injecting powerful features and flexibility into your projects.

Guess you like

Origin blog.csdn.net/cheungxiongwei/article/details/132516321