Home  >  Article  >  Web Front-end  >  How to download a specified version of nodejs

How to download a specified version of nodejs

PHPz
PHPzOriginal
2023-04-26 09:08:245132browse

Node.js is a very popular JavaScript running environment and is widely used in server-side development, command line tools, web development and other fields. Since Node.js is constantly updated and iterated, there are some changes and new features in each version. Therefore, sometimes it is necessary to download a specific version of Node.js for specific application scenarios.

This article will introduce how to download the specified version of Node.js.

1. Understand the Node.js version naming rules

Before downloading the Node.js version, we need to understand the Node.js version naming rules. The official version number of Node.js is based on the SemVer (Semantic Version) specification. The format of each version number is MAJOR.MINOR.PATCH, where:

  • MAJOR represents the major version number. Node.js with the same MAJOR version number can be compatible, but may not be backward compatible.
  • MINOR represents a minor version number. Changes to the MINOR version number include new features and bug fixes, and are backward compatible.
  • PATCH represents the patch version number, which only contains bug fixes and is backward compatible.

In addition, Node.js also has some version names that are different from the standard SemVer specification, such as LTS version and the latest stable version.

2. Download the specified version of Node.js through nvm

nvm (Node Version Manager) is a very convenient Node.js version management tool that allows us to easily manage different versions of Node.js. Switch between Node.js. Before using nvm to download the specified version of Node.js, we need to install nvm. Here we take the macOS system as an example. For other operating systems, you can refer to the official documentation of nvm for installation.

  1. Install nvm

Execute the following command in the terminal to install nvm:

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash

Note: After installing nvm, you need to restart the terminal to use the nvm command.

  1. View available versions

Execute the following command to view available Node.js versions:

nvm ls-remote

The latest Node.js version will be at the top. If you need to view a specific version of Node.js, you can search through filters, for example, find the v14.18.1 version:

nvm ls-remote | grep 'v14.18.1'
  1. Install the specified version

Execute the following command to install Specified version of Node.js:

nvm install v14.18.1

After the installation is complete, you can view the installed Node.js version through the following command:

nvm ls
  1. Use the specified version

Execute the following command in the terminal to switch to the specified version of Node.js:

nvm use v14.18.1

You can use the following command to verify whether the Node.js version is switched successfully:

node -v

3. Through the official website Download the specified version of Node.js

If you do not want to use nvm to manage the Node.js version, you can also directly download the specified version of Node.js through the official website of Node.js.

  1. Open the official website of Node.js

Enter https://nodejs.org/ in the browser to open the official website of Node.js.

  1. Select the download version

On the home page of the official website, click the "Download" button to enter the download page. On the download page, we can choose from a variety of Node.js versions for different operating systems.

If you need to download a specified version of Node.js, you can find the version we need in the "Previous Releases" tab, click on the corresponding version number to enter the download page.

  1. Download and install Node.js

In the download page, you can choose to download the corresponding version of the Node.js installer for installation. After the installation is complete, you can execute the following command in the terminal to verify whether Node.js is installed successfully:

node -v

4. Summary

This article introduces how to download the specified version of Node.js. Node.js versions can be easily managed using the nvm tool. At the same time, the official Node.js website also provides Node.js installation programs for various operating systems to facilitate users to download and install specified versions of Node.js. No matter which method is used, you need to understand the naming rules of the Node.js version before downloading to ensure that the downloaded version meets our needs.

The above is the detailed content of How to download a specified version of nodejs. 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