Semver carets and tilde in npm
If you use npm you have likely seen notation for dependencies in your package.json like ^4.2.7 or ~3.5.3 , etc. Those are respectively caret ranges and tilde ranges . They are well documented on the npm website . And while I have become quite familiar on how to use them, I had an epiphany recently that I thought I would share. This could help newbies navigate these powerful yet odd notation. The main power of those notations versus their easier-to-understand cousins x , X and * is that you can fix the lowest version . This is usually critical, because when everybody follows semantic versioning, a library is backward compatible , but your code, as the consumer, does not have to be. Actually, it is only forward compatible . Let’s say you use a library called foo . The authors of foo , at version 1.2 decide to introduce a cool new bar() method in their package. You want to take advantage of bar() in your code. If you used the x notation in your package.json , like this: ...