fix(scripts): consistently use caret version when updating dependencies both in package.json and in npm scripts #7319
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Le Roux ran into an interesting issue when trying to bump
@leafygreen-ui/lib
just one minor version up that was causing the update-dependencies script (or just a normal npm install) to fail on the last step with the following error:I traced it back to some slightly unexpected behavior in npm internals. Usually if you'd run
npm install library@version
, ifversion
doesn't contain a range of any sort, npm will install specified version and add it to package.json with a caret:"library": "^version"
. Before it does that though, it runs a check againstoverrides
field in package.json, and the version spec must match exactly what's in there for it to pass. In this case15.3.0
that we are trying to install would not be equal to^15.3.0
even if it's a matching range and will end up in the package.json in the same form and npm fails.The fix is quite straightforward: just make sure that we consistently use caret range everywhere in the update script.