Home  >  Article  >  Web Front-end  >  nodejs download and install Linux

nodejs download and install Linux

WBOY
WBOYOriginal
2023-05-13 16:30:39660browse

Node.js is a JavaScript runtime based on the Chrome V8 engine, which allows the JavaScript runtime environment to be extended to the server side. It effectively solves the problem of inconsistency between front-end and back-end languages, allowing front-end developers to use JavaScript for full-stack development.

This article will introduce how to download and install Node.js on a Linux system.

Step 1: Install Node.js

In order to install Node.js on Linux, you first need to download it from the Node.js official website [https://nodejs.org](https:// nodejs.org/) to download the latest version of Node.js installation files.

Enter the download directory through the terminal and decompress the download file:

cd ~/Downloads
tar -xvf node-v14.15.3-linux-x64.tar.xz

The above command assumes that you are already in the download directory and have downloaded the installation file of Node.js version 14.15.3. Please make corresponding modifications according to the version number of the file you downloaded.

After decompression is completed, move the Node.js directory to the /usr/local/ directory:

sudo mv node-v14.15.3-linux-x64 /usr/local/

Next, set the Node.js environment variable through the following command:

export PATH=$PATH:/usr/local/node-v14.15.3-linux-x64/bin

In order to permanently save the environment variables, you need to add the above command to the end of the ~/.bashrc file:

sudo nano ~/.bashrc

Add the following content in the .bashrc file:

export PATH=$PATH:/usr/local/node-v14.15.3-linux-x64/bin

After the addition is completed, save and Exit the .bashrc file and reload the environment variables via the following command:

source ~/.bashrc

Now Node.js has been successfully installed and can be verified via the node command:

node -v

The above command will output on that system Version information for Node.js.

Step 2: Install the Node.js package manager - npm

The Node.js package manager npm allows users to easily download and manage Node.js modules. After installing Node.js, npm is installed by default.

The following command can check the version information of npm:

npm -v

If the version information is output, it means that npm has been successfully installed.

Conclusion

Installing Node.js on a Linux system is very easy. First download the latest version of the binary file from the Node.js official website, then unzip it to the appropriate directory and add it to the system's PATH. Next, you can use the node and npm commands in the terminal to operate and manage the Node.js environment.

The above is the detailed content of nodejs download and install Linux. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn