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

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

    semver is separate in to 3 major sections which is broken by dots.

    major.minor.patch
    1.0.0
    

    These different major, minor and patch are using to identify different releases. tide (~) and caret (^) are using to identify which minor and patch version to be used in package versioning.

    ~1.0.1
     Install 1.0.1 or **latest patch versions** such as 1.0.2 ,1.0.5
    ^1.0.1
     Install 1.0.1 or **latest patch and minor versions** such as 1.0.2 ,1.1.0 ,1.1.1
    

提交回复
热议问题