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

后端 未结 19 1850
温柔的废话
温柔的废话 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:56

    One liner explanation

    The standard versioning system is major.minor.build (e.g. 2.4.1)

    npm checks and fixes the version of a particular package based on these characters

    ~ : major version is fixed, minor version is fixed, matches any build number

    e.g. : ~2.4.1 means it will check for 2.4.x where x is anything

    ^ : major version is fixed, matches any minor version, matches any build number

    e.g. : ^2.4.1 means it will check for 2.x.x where x is anything

提交回复
热议问题