Since NPM v7 the official docs state the following about npm install (emphasis mine):
This command installs a package and any packages that it depends on. If the package has a package-lock, or an npm shrinkwrap file, or a yarn lock file, the installation of dependencies will be driven by that
I was trying to find more information about npm install behavior with the yarn.lock present, but didn't find much. This blog post states:
With the new
package-lock.jsonfile we'll unlock the ability to do deterministically reproducible builds. It should now include everything npm needs to install the packages needed. Before npm 7yarn.lockwas ignored by npm, but this is no longer the case. It can now use it to keep itself up to date with the package tree.
GitHub blog:
In prior versions, the yarn.lock files were ignored, the npm CLI can now use yarn.lock as the source of package metadata and resolution guidance. If a
yarn.lockfile is present, then npm will also keep it up-to-date with the contents of the package tree.
But neither of them gives a clear picture of what actually happens when I run npm install with yarn.lock.
I'd like to get a grasp on it:
- Can I run
yarnlocally to generateyarn.lockand reproduce the package tree on CI withnpm install? - What exactly happens when I run
npm installwithyarn.lock? Does it get updated? Can it be run with (sort of)--frozen-lockfile? Thenpm cicommand doesn't mentionyarn.lockat all. - Does it support both
v1andberry?