Home >Web Front-end >Front-end Q&A >nodejs download and install Linux
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.
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.
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.
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!