What's the difference between tilde(~) and caret(^) in package.json?

后端 未结 19 2078
温柔的废话
温柔的废话 2020-11-22 00:31

After I upgraded to latest stable node and npm, I tried npm install moment --save. It saves the entry in the package.json

19条回答
  •  长情又很酷
    2020-11-22 00:39

    See the NPM docs and semver docs:

    • ~version “Approximately equivalent to version”, will update you to 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 to all future minor/patch versions, without incrementing the major version. ^2.3.4 will use releases from 2.3.4 to <3.0.0.

    See Comments below for exceptions, in particular for pre-one versions, such as ^0.2.3

提交回复
热议问题