Tilde (~) vs Caret (^) in package.json file
In this post we will give you information about Tilde (~) vs Caret (^) in package.json file. Hear we will give you detail about Tilde (~) vs Caret (^) in package.json fileAnd how to use it also give you demo for it if it is necessary.
we are going to learn about the difference between tilde (~) and caret (^) in the package.json file.
When we install a new package using npm install <package-name> command, it will add a reference inside package.json file by prefixing the package version with tilde ~ or caret ^.
Example:
npm install express
Now, inside package.json npm will add it like this.
"dependencies": { "express": "^4.17.1" }
The version has three numbers (4.17.1) which are major.minor.patch based on semantic versioning.
Tilde (~)
If the version number is prefixed with a tilde (~), it will only update the patch version in the future, without updating the major and minor versions when we run a npm update command.
~2.13.4 means npm will only update the releases from 2.13.4 to <2.14.0 .
Caret (^)
If the version number is prefixed with caret (^), it will only update the minor and patch versions in the future, without updating the major version when we run a npm update command.
^4.17.1 means npm will only update the releases from 4.17.1 to <5.0.0 .
Hope this code and post will helped you for implement Tilde (~) vs Caret (^) in package.json file. if you need any help or any feedback give it in comment section or you have good idea about this post you can give it comment section. Your comment will help us for help you more and improve us. we will give you this type of more interesting post in featured also so, For more interesting post and code Keep reading our blogs