3
头图

Node.js is a JavaScript runtime environment based on the Chrome V8 engine.
In our daily development, Node.js is used in more and more scenarios, ranging from server-side projects to development tool scripts, so it is very necessary to master some basic knowledge of Node.js.
Today I mainly talk about the difference between LTS and Current in Node.js and how to choose the appropriate version.

1. Version introduction

On the official website, you can see that Node.js has LTS series and Current series, which correspond to different latest version numbers.

nodejs
(This picture comes from: Nodejs )

The version number naming of Node.js follows Semantic Versioning , a unified version number representation rule, which specifies how the version number is represented, how to increase, how to compare, and what different version numbers mean.

Version format: 主版本号.次版本号.修订号

  • Major version number (major): when you make incompatible API changes,
  • Minor version number (minor): When you add functionality that is backward compatible, it can be understood as the Feature version.
  • Revision number (patch): When you make a correction for backward compatibility, it can be understood as the Bug fix version.

2. LTS version

The full name of the LTS version is Long Time Support , that is, the long-term support version . The focus is on stability and security. The major version number of each LTS version is an even number . It is recommended to select the LTS version for the first download and each subsequent upgrade to reduce the development process. An unknown problem occurred.
LTS releases have a 3-phase lifecycle:

The life cycle meaning illustrate
Active active stage Every even-numbered version that enters the LTS from Current is actively maintained and upgraded for 18 months.
Maintenance maintenance phase After the active phase reaches 18 months, it will enter a maintenance phase of 12 months, during which only bug fixes and security patches will be made.
End of Life end stage Referred to as EOL, after the maintenance phase reaches the deadline, the version enters the EOL phase and will no longer be maintained. That is to say, each LTS version will have a maintenance period of up to 30 months, and will no longer be maintained after that.

Lifecycle diagram for releases (2022-2025):

nodejs
(Image from: Node.js )

3. Current version

Current is the latest release, which focuses on the development of necessary features and refinement of existing APIs, with a shorter lifespan and more frequent code updates.
You can experience the latest features in this version, and you may encounter various unexpected issues and compatibility to deal with.
Usually the Current version will release a major version every 6 months (except in special cases):

  • A new even-numbered version is released every April;
  • A new odd-numbered version is released every October.

nodejs releases
(Image credit: Node.js releases )

For detailed version update records, see Node.js releases .

4. How to choose the right version?

  • Use the LTS version

Generally used in production environments, the focus is on stability, if you need stability and have a complex production environment (such as a medium or large enterprise), it is recommended to use the LTS version.

  • Use Current version

Generally used in test environments, if you are trying out new versions and new features (such as new ECMAScript features), or to be able to quickly and easily upgrade versions without disturbing the environment, it is recommended to use the Current version.

V. Summary

This article mainly talks about the difference between LTS and Current in Node.js and how to choose the appropriate version. In actual development, it is not necessary to update to the latest version in time. We can decide whether to use the minimum Node.js version that the project technology stack depends on. Upgrade, if conditions permit, it is recommended to at least upgrade the major version to the latest LTS version.


pingan8787
3.2k 声望4.1k 粉丝

🌼 前端宝藏小哥哥