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

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

    The version number is in syntax which designates each section with different meaning. syntax is broken into three sections separated by a dot.

    major.minor.patch 1.0.2

    Major, minor and patch represent the different releases of a package.

    npm uses the tilde (~) and caret (^) to designate which patch and minor versions to use respectively.

    So if you see ~1.0.2 it means to install version 1.0.2 or the latest patch version such as 1.0.4. If you see ^1.0.2 it means to install version 1.0.2 or the latest minor or patch version such as 1.1.0.

提交回复
热议问题