NPM Package: diff between ~ and ^

Bittu Kumar
Apr 3, 2024

--

Do you know difference between ~ and ^ in package.json

If you’re working regularly on Node.js-based projects, it’s crucial to understand difference between Tilde( ~ ) and Caret( ^ ) for effective package management.

mentioning any one ~ or ^ will help prevent automatic update of major version if we do `npm update`

NPM package version: ( Major.Minor.Patch )
Example :
📋 ~3.1.2 would allow updates for patch versions: 3.1.x, but it would keep the major and minor versions locked.
📋 ^3.1.2 would lock the major version to 3 and allow updates for minor and patch versions: 3.x.x

Thanks for reading till here, You can follow me if you like this article and learnt something new.

You can find me here for any further discussion:

https://www.linkedin.com/in/bittukumar-web/

--

--

Bittu Kumar
Bittu Kumar

Written by Bittu Kumar

Exploring Angular and Frontend development.

No responses yet