Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the differences between lts and current of nodejs

2025-03-04 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly introduces "what are the differences between nodejs's lts and current". In daily operation, I believe many people have doubts about the differences between nodejs's lts and current. Xiaobian consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful to answer the questions of "what are the differences between nodejs's lts and current?" Next, please follow the editor to study!

Difference: Current refers to the latest node version currently released, which contains the latest features, but will be unstable and will be updated, optimized or fixed from time to time, while LTS refers to the long-term supported node version, that is, the stable version, which contains stable functions.

This tutorial operating environment: windows7 system, nodejs version 12.19.0, DELL G3 computer.

Go to the nodejs official website to download https://nodejs.org, there are two versions of LTS and Current. What's the difference? Which one should I choose. Of course, if you know the difference, you will know which version to choose.

Summary of the difference between LTS and Current: in fact, a new and an old can be seen from the version number. Current is the latest version, and all the latest features are in it. Is to give you a trial test, if everyone is all right, the function is stable, release to the LTS version. So LTS is the stable version.

Let's talk about the version plan of nodejs.

Node.js LTS plan

After the merger of Node.js and io.js, Node.js core began to use LTS (Long Term Support) to plan the release cycle in order to ensure a stable and orderly release and enable developers to arrange upgrades reasonably. The first version of LTS, v4, was released in October 2015. Under this plan, the version of Node.js is equivalent to a snapshot of the master branch that has been stabilized at a specific time. When the time is up, the stable part of the master branch will be integrated and a new version will be released. Therefore, the release of Node.js is based on the passage of time and skips the version on the premise of ensuring compatibility, not on the number of compatibility and new features. This also explains why the Node.js version seems to jump so fast (not "Oh, we've saved so many tricks to release a new version!" But "Ah, it's time to release the edition in April. Let's go over what we have saved and see if it is stable enough to add it, although it may not be very big."... " ). It is worth mentioning that the current evergreen browser / mainstream JavaScript engine / ECMAScript standard / C++ standard also adopts a similar principle, taking the time span as the basis, intercepting stability features from the backbone to release.

Each LTS will have a code name, take the name of the element from the periodic table, sort it alphabetically, and pick out the appropriate one. The code name for v4 is Argon (argon) and the code name for v6 is Boron (boron).

Node.js version naming rules follow the semantic version (Semantic Versioning), the version number is divided into three parts, the first number (semver-major) increases, indicating an incompatible change; the second number (semver-minor) increases, indicating a new feature to maintain compatibility; and the third number (semver-patch) increases, indicating changes while keeping compatibility and features unchanged, such as fixing the bug or improving the document. This naming convention has its pros and cons, which will not be discussed here, but some of its inconsistencies make some exceptions to Node.js naming, such as semver-minor in order to update to all major versions, even if a security update leads to incompatibility.

How do Node.js application developers choose?

For Node.js application developers who pursue stability, they only need to follow up the upgrade online when one version becomes active LTS every October, that is, the major version is updated every 12 months, and each upgrade version has a life span of 18 months + 12 months. When following up on minor and patch, you don't have to worry too much about compatibility issues. The current recommendation is that it is best to complete the online upgrade within 12 months of the release of an active LTS (because the next active LTS will be available in 12 months). If you are behind schedule, compromise to 18 months, or before the end of the active period of LTS. If you can't catch up, at least the upgrade will be completed before the end of the life of this version within 30 months, otherwise there will be no security updates.

If you are worried that the direct upgrade will encounter more compatibility problems, you can test and prepare the upgrade offline in advance when the even-numbered version comes out in April every year, and report the problem to the community (of course, if you are not free, you don't need to take care of this step). And continue to follow up, and upgrade the online version in October. In this way, major will rise once every 12 months above and below the line, but at a different time. Although there are more compatibility issues to follow up offline, you can also use feedback to allow your compatibility needs to be taken care of by the community.

If you are keen to try new features, or experimental projects that are not used in a production environment, try the odd-numbered version of major released every October. Each odd-numbered version will only last eight months, and there will be no LTS compatibility guarantee, but Node.js developers will use this version to prepare for the next LTS, so it will make more bold attempts, such as more frequent v8 updates (meaning more ECMAScript new features and performance optimizations).

As a result, developers who are still using v4.x online are ready to upgrade to v6.x. If your online applications are still using versions released before LTS is planned to be enabled, such as v0.12.x, it is also best to upgrade to v4.x or above, because there will be no security updates for v0.12.x after December 2016, let alone earlier versions, mainly because OpenSSL vulnerabilities will not be fixed and these applications will be exposed to various security risks. Once you upgrade to v4.x or higher, future upgrades will be much easier, as long as you remember to follow minor or patch, or lazy ones just need to pay attention to security updates.

How does this correspond to the source code of Node.js?

First of all, Node.js 's Github Repo has a master branch, and most of the commit is submitted to this branch through PR. Depending on whether these commit have changed compatibility or introduced new features, they will be labeled semver-major or semver-minor.

When you need to prepare LTS before April each year, Node.js will intercept a new branch from the master branch. If this is V6, then this branch is called v6.x-staging. After that, the changes related to the LTS / intend to go into the changes to the LTS, such as bug repair, etc., or submit the PR to master, but you need to add a tag lts-watch-v6.x. After being merged into master, these changes are singled out by the person in charge of the release and merged into v6.x-staging. When one day in April, the first version of V6 can be released, the person in charge of the release will create a v6.x branch, pick out the changes and merge them from v6.x-staging. From April to October, all changes to V6, whether minor or patch, are still submitted from PR to master, then singled out to v6.x-staging, and then released to V6.x. In this way, master always keeps the latest changes. The branches related to other versions are all microcosms of commit selected from master for distribution. V6.x-staging retains the changes related to v6.x LTS, and v6.x retains each V6 release. With the exception of the people who handle the branches, other developers will not touch the branches related to these versions.

At this point, the study on "what is the difference between lts and current of nodejs" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report