I'm looking for an equivalent for yarn's --pure-lockfile
flag.
This flag is useful when installing dependencies in CI, when you want it to read your lockfile but not modify it.
Does npm v5 have an equivalent?
Lock files ensure that the defined dependencies from files such as package. json get pinned to specific versions. This later ensures parity on developers' workstations, CI, and production. Many people probably depend on Yarn doing the right thing and installing only the pinned versions from yarn.
Simply install syncyarnlock, and execute with the options applicable to your needs. For example, to sync a project's package. json with the project's yarn. lock, and have the ranges remain intact while updating the versions to reflect what will actually be installed, simply run: syncyarnlock -s -k .
The `package-lock. json` file was introduced in npm version 5 to solve this problem. It is a generated file and is not designed to be manually edited.
What's a Lock FileLock FileFile locking is a mechanism that restricts access to a computer file, or to a region of a file, by allowing only one user or process to modify or delete it at a specific time and to prevent reading of the file while it's being modified or deleted.https://en.wikipedia.org › wiki › File_lockingFile locking - Wikipedia? A lock file describes the entire dependency tree as it is resolved when created including nested dependencies with specific versions. In npm these are called package-lock. json and in yarn they are called yarn. lock .
npm 5.7 introduced the npm ci
subcommand:
the main differences between using
npm install
andnpm ci
are:
- The project must have an existing
package-lock.json
ornpm-shrinkwrap.json
.- If dependencies in the package lock do not match those in
package.json
,npm ci
will exit with an error, instead of updating the package lock.npm ci
can only install entire projects at a time: individual dependencies cannot be added with this command.- If a
node_modules
is already present, it will be automatically removed beforenpm ci
begins its install.- It will never write to
package.json
or any of the package-locks: installs are essentially frozen.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With