This is the 28th day of my participation in the August Challenge

The first step to learning how to use Node.js is to download and install it, but do you know what to choose from and why?

This section describes node.js versions

The installation

Node.js is a cross-platform JavaScript runtime environment based on the Google V8 engine

Download and install the software directly from 👉

Version is introduced

How to choose?

When downloading from the official website, you will see two versions of LTS and Current can be downloaded. How to choose?

The short answer is [choose LTS]

Why?

Interpretation of LTS and Current

First, LTS and Current are not versions, but phases of the same major number (” major number “is semver-major).

Current:

A new major release is followed by the Current phase, which lasts for six months to give library authors time to support the new version. After six months, the odd-numbered versions (such as 9, 11, etc.) will become unsupported, and only the even-numbered versions (such as 10, 12, etc.) will become Active LTS and ready for use (even-numbered versions in April and odd-numbered versions in October each year).

LTS (Long Term Support) :

The status of the LTS release is long Maintenance. It has two phases: Active LTS and Maintenance LTS. The Active LTS phase lasts for 18 months, and the Maintenance LTS version will be upgraded after the Active LTS phase expires. The EOL version will be upgraded after the Active LTS phase expires.

The life cycle

conclusion

  • If you are in a test environment and want to try out some new features, download Current;

  • If you are in production, LTS should be selected for stability, and you can follow up with updates every year when Active LTS releases are released. Update time should not exceed 30 months, since EOL is available after 30 months.

Some terminology

Active: a release family that is being actively maintained and upgraded, including backward migration of non-destructive features and improvements, bug resolution, and security vulnerabilities.

Maintenance: This is a series of LTS releases that are maintained until the end of its life cycle, only receiving bug fixes and security patches for a short period of time

EOL: EOL is an acronym for End of Life. The version entered into the EOL timeline will no longer be maintained.


Semver-major, by the way

Semver refers to the Semver specification, and Github has drafted a guiding, unified version number representation rule called Semantic Versioning. This rule specifies how version numbers are represented, how they are added, how they are compared, and what different version numbers mean.

Semver website

Semver official website Chinese version

Major indicates the major version number. The version format is: major version number. The second version number. The increment rule is as follows:

  • Major: When you make incompatible API changes,
  • Minor: When you make a backward-compatible Feature addition, which can be interpreted as a Feature version,
  • Patch: When you make a backward-compatible issue fix, it can be understood as a Bug fix version.

References:

node releases

Node.js Release Working Group

Node.js version management

How do I quickly switch node.js versions?


There are several ways:

nNPM is a global open source package that relies on NPM for global installation and use

As you can see, Node has a module called n. , which is used to manage versions of Node.js (and is more commonly used).

Installing the N module

npm install -g n
Copy the code

Viewing the Installed Version

n --version
Copy the code

Upgrade Node.js to the latest stable version

n stable
Copy the code

Upgrade any version, n followed by the version number

N v14.17.5 or n 14.17.5Copy the code

Common commands

View the Node version node --version View the NPM version and check whether the NPM is correctly installed. NPM - v CNPM (domestic taobao mirror image source), is mainly used for downloading some packages or the command program without down NPM install CNPM - g - registry=https://registry.npm.taobao.org NPM list of installed modules listCopy the code


fnm: fast and simple, compatible with. Node-version and. NVMRC files

This is a fast and easy management tool for multiple node.js releases built with Rust.

FNM has cross-version support (macOS, Windows, and Linux), as well as a range of derived commands (Bash, Zsh, Fish, PowerShell, Windows command line)

Making the address


nvm: Independent software package, Node Version Manager

NVM is a project for Mac/Linux users only, while NVM-Windows is an alternative to it on the Windows platform, and the two are related but separate projects;

NVM – Windows download

conclusion

If any of the above is wrong, please point out in the comments section!


If there is a harvest, leave a thumbs-up to encourage it! 🍜