In case an application has a package-lock.json or shripkwrap.json, both npm install/npm ci command would honor the dependencies versions (in package-lock.json or shripkwrap.json), what purpose would tilde(~) and caret(^) serve in package.json?
Asked
Active
Viewed 276 times
3
-
npm allows installing newer version of a package than the one specified. Using tilde ( ~ ) gives you bug fix releases and caret ( ^ ) gives you backwards-compatible new functionality as well. – Shivanshu Gupta Jun 24 '20 at 17:00
-
Does this answer your question? [What's the difference between tilde(~) and caret(^) in package.json?](https://stackoverflow.com/questions/22343224/whats-the-difference-between-tilde-and-caret-in-package-json) – Shivanshu Gupta Jun 24 '20 at 17:08
1 Answers
0
Tilde ~
and caret ^
are used in package.json to say that your software is compatible with new patch or minor versions of a specific dependency.
But as you've identified, npm install
ignores new patch or minor versions when a package-lock.json file is present.
Instead, run npm update
.
This installs the latest version of any dependencies, based on how you've defined the version in package.json. It also updates package-lock.json accordingly.

Tom Gregory
- 105
- 6