6

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

 2 years ago
source link: https://blog.bitsrc.io/difference-between-tilde-and-caret-in-package-json-bc9e59b125df
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

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

There is a lot of confusion going around when it comes to the difference between tilde and caret inside your package.json file, which can end up in a mess on the production side since you might update accidentally to the version of a dependency that you did not test for production.

In today’s article, I wanna clarify the differences between these two concepts.

Photo by Blake Connally on Unsplash

~version (approximately equivalent to version)

Will update you on all future patch versions, without incrementing the minor version. ~1.2.3 will use releases from 1.2.3 to <1.3.0.

^version (compatible with version)

Will update you on all future minor/patch versions, without incrementing the major version. ^2.3.4 will use releases from 2.3.4 to <3.0.0.

Thanks for reading my short article about this topic. I hope, I could refresh your knowledge.

Cheers!

Use any component in all your projects

Up until now, you used to build features hidden inside larger projects.

But what if you were to develop independent features first, and then easily compose and manage them in many applications? Your development will become faster, more consistent, and more scalable every day. Create a component once, and truly use it anywhere to build anything.

OSS Tools like Bit offer a powerful developer experience for building independent components and composing them to applications. You can start small with a nice project, some shared components, or even trying out Micro Frontends. Give it a try →

0*hX30HLO0QBJky-kT?q=20
difference-between-tilde-and-caret-in-package-json-bc9e59b125df
An independent product component: watch the auto-generated dependency graph

Learn more


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK