Version constraints in JSON files
By Mike Street
While running through my "recent" 11ty upgrade I got caught out by a version contain syntax difference between Composer and NPM.
I use Composer a lot at work so am used to the syntax it has - this whole post centres around the caret (
When specifying a package and a version, the caret signifies:
- on NPM
2.x.x(All minor versions)
- on Composer
2.0.x(Only bug fixes)
Composer allows the last number you specify to be incremented freely, so you can set
^2.0 to get all minor versions and bug fixes for version 2.
To be a bit more verbose, if our package had the following tags:
If you had
^1.1.0 you would go up to
If you put
^1.1 you would get all the way up
- If you had
^1.1.0you would go up to
- If you put
^1.1you would get all the way up
- If you wanted just bug fixes, you would do
~1.1.0which would stop at
It's a small difference that could have a big impact on the packages your site uses.