Home  >  Article  >  Web Front-end  >  Nodejs download and installation

Nodejs download and installation

PHPz
PHPzOriginal
2023-04-17 15:03:11130browse

Node.js is a JavaScript runtime based on the Chrome V8 engine that can be used for server-side programming. It takes its name from its event-driven, non-blocking I/O model, making it lightweight, efficient, and easily scalable. This article will introduce the download and installation process of Node.js.

1. Download Node.js

To obtain the original code of Node.js, you can download it from the official website. Open the https://nodejs.org/zh-cn/download/ page, you can see the download page, select the corresponding version to download as needed.

Node.js provides three options: LTS, Latest and other versions. LTS releases (also known as "Long Term Support" releases) are versions of Node.js that are expected to have long-term support. The Latest version is the latest released version and can also be used. Other versions include those designed for specific application scenarios.

It is recommended to download the LTS version here. Just click the button to download the LTS version.

2. Install Node.js

Before installing Node.js, please close all installed programs. The installation process is divided into the following steps.

  1. Execute the downloaded file

After the file download is completed, double-click to open the installation program. There will be following options.

  • Regular users: Select the "Install" tab, click the "Install" button, and then follow the installation wizard to complete the installation process.
  • Advanced users: can customize the installation path and other options.
  1. Configuring environment variables

Whether it is on Windows, Linux or Mac operating systems, you need to configure environment variables after the installation is complete. The purpose of environment variables is to allow the system to recognize the commands provided by Node.js.

In the Windows operating system, you can find "Properties" in "My Computer". Select "Advanced System Settings", then go to the "Environment Variables" option, find "Path" in the system variables, and add the Node.js installation path to it.

In Linux or Mac operating systems, you can run the following command on the console:

vim ~/.bashrc

Add this line at the end of the command line (replace the path yourself , do not copy)

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

After saving, execute the following command to make the information configured in the file take effect immediately:

source ~/.bashrc
  1. Verify version

After the installation is complete, enter the following command in the terminal to verify whether the node is successfully installed:

node -v

If the installation is successful, the following information will be returned in the terminal:

v14.17.5
  1. Install NPM

Installing Node.js also automatically installs the Node.js package management tool, also known as NPM. NPM is an extension and component library for Node.js. NPM manages a large number of Node.js packages. Using NPM is similar to using Maven or Nuget in a programming environment like Java or .NET.

In order to confirm whether NPM is installed successfully, please enter the following command in the terminal window:

npm -v

If NPM is installed successfully, the following information will be returned in the terminal:

7.20.3

If the following content is output:

Command 'npm' not found

It means the Node.js installation failed.

Conclusion

Through the above steps, we have completed the download and installation of Node.js. Node.js is the core of the entire Node.js ecosystem, which helps developers create fast, highly scalable, and easy-to-code-manage web applications. Node.js can also be used as a web development tool for developing RESTful APIs and providing a Javascript runtime environment.

The above is the detailed content of Nodejs download and installation. 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