Caret (^) and Tilde (~) in package.json
NPM

Caret (^) and Tilde (~) in package.json

What does this mean for you?

Well, first you should understand the difference between the two.

In the simplest terms, the tilde matches the most recent minor version (the middle number).

`~1.2.3` will match all `1.2.x` versions but will miss `1.3.0`.

This has been the default behaviour of ‘–save’ since the start, and you are probably already comfortable seeing it in your package.json.



The caret, on the other hand, is more relaxed.

It will update you to the most recent major version (the first number). `^1.2.3` will match any `1.x.x` release including `1.3.0` , but will hold off on `2.0.0`.

NPM’s semver parser relies on this sanity, so the tilde’s behavior for matching “reasonably close” versions can remains unchanged. The caret, however, won’t work with this new rule. To maintaining compatibility, it must be similarly conservative and only match the minor version.

So for version zero software, the caret behaves like the tilde.

Both `~0.1.2` and `^0.1.2` will match the most recent 0.1 software, but ignore `0.2.x` since it could be incompatible.

You probably won’t notice anything immediately, and your package.json file is still fine as it is. But next time you save a dependency you may notice a caret has crept into your package.json. ??

Hope you like it.

Follow ?? for More new Articles on Angular, Mongodb, Nodejs.

Stay Connected !

要查看或添加评论,请登录

Hardeep Singh的更多文章

  • Culture of Giving & Taking Feedbacks

    Culture of Giving & Taking Feedbacks

    Every person has its own way to handle feedback. Some are good at giving feedback and some are great at obeying those…

  • Why “ReDuX AcTiOnS” !!!

    Why “ReDuX AcTiOnS” !!!

    Before we start about redux-actions, we will start with simple actions. Now what are actions, they are just dumb…

  • Introducing React JSX Forms

    Introducing React JSX Forms

    Hey everyone !! Hope you good there. This article is for those who want to develop react application with react forms.

  • Deal With Excel Sheets in Objects

    Deal With Excel Sheets in Objects

    Hi All ! Hope you good there. This Article is mainly for those who are dealing with Excel Sheets OR CSV Sheets and…

  • Cook your Toast with Cook-Toast (ANGULAR)

    Cook your Toast with Cook-Toast (ANGULAR)

    So Hi everyone hope you good there ! This Article is mainly for Front-End Developers on WEB, who are basically working…

  • Use Rest Operators ( … ) || ES6

    Use Rest Operators ( … ) || ES6

    What the heck are Three Dots || Rest Operator ? Same question get arise when I was learning the concepts of ES6. So…

社区洞察

其他会员也浏览了