When using package manager like yarn or npm it will create a lock file such as yarn.lock
, package-lock.json
& Gopkg.lock
These lock files need to be committed to the repo to ensure that every install results in the same file structure in node_modules across all machines (including CI server caching).
Yarn
- Add
yarn.lock
to the repository and commit it - Use
yarn install --frozen-lockfile
and NOTyarn install
as a default both locally and on CI build servers.
NPM
- commit the
package-lock.json
. - use
npm ci
instead ofnpm install
when building your applications both on your CI and your local development machine