3 ms·
Semver explained – why there's a caret (^) in my package.json?
- lemevi 11y agoI've seen those characters in package.json but I never really bothered to look up how they worked, but now I will use them. Great article. I wonder though why they didn't go with using asterisk instead? Like say you used 1.. in package.json, now you'll get all updates up until 2.0.0 comes out.
- function_seven 11y ago> Like say you used 1.∗.∗ in package.json, now you'll get all updates up until 2.0.0 comes out. I think the caret and tilde indicate that the package must be at the given version or greater. Asterisks wouldn't allow you to specify a lower bound. (HN's comment system ate your asterisks. I don't know how to get around that, so I replaced them with U+2217 chars)
- bytearcher 11y agoIt's most likely due to backwards incompatibility. Major version update (1.x.x -> 2.0.0) breaks something and npm wants to play it safe, which is very understandable.
- benatkin 11y agoThere's an error here: > Lets say you are using version 1.3.4 of a library with a caret (~) as your dependency. s/caret/tilde/ Awesome post! This is very important and needs to be presented in simple terms.
- bytearcher 11y agoThanks so much for pointing out! Consistent effort was made to always pair the symbol with the keyword "tilde (~)" but it still managed to wrong once :)