On a project I have replaced npm with yarn to get the benefits of it, and also enforce our dependencies are locked in via the yarn.lock
.
Now, a developer added a library with npm@4, which only changed the package.json
, and not of course the yarn.lock
.
I would have expected the yarn install
command to crash on the build server, yet yarn has the--to me unexpected behavior--of adding those libraries in their most current version and then updating the yarn.lock
on the remote:
$ yarn install
[1/4] Resolving packages...
[2/4] Fetching packages...
warning fsevents@1.1.2: The platform "linux" is incompatible with this module.
info "fsevents@1.1.2" is an optional dependency and failed compatibility check. Excluding it from installation.
[3/4] Linking dependencies...
[4/4] Building fresh packages...
success Saved lockfile.
Done in 5.07s.
This contradicts yarn's purpose, as the build job does not push the yarn.lock
back to the repository nor should it.
I want each developer to be responsible of the version they are checking in.
Hence, is there a way to have yarn install
exit with an error code if the package.json
and yarn.lock
are out of sync?