Difference between tilde (~) and caret (^) in package.json

All npm packages contain a file, usually in the project root, called package. json — this file holds various metadata relevant to the project. This file is used to give information to npm that allows it to identify the project as well as handle the project’s dependencies.
So when we are installing new packages and get your package.json updated.
Taking a closer look, you notice that there’s something in front of the version numbers.

"dependencies": {
"library_Name": "^3.9.2"
}

npm uses the tilde (~) and caret (^) to designate which patch and minor versions to use respectively.

So if you see ~1.0.2 it means to install version 1.0.2 or the latest patch version such as 1.0.4
If you see ^1.0.2 it means to install version 1.0.2 or the latest minor or patch version such as 1.1.0.

Thanks for reading!!!!!!!

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store