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

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

    Tilde (~)

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

    "express": "~4.13.3" 
    

    ~4.13.3 means it will check for 4.13.x where x is anything and 4.14.0

    Caret (^)

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

    "supertest": "^3.0.0"
    

    ^3.0.0 means it will check for 3.x.x where x is anything

提交回复
热议问题