Committing lock files to repo

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

  1. Add yarn.lock to the repository and commit it
  2. Use yarn install --frozen-lockfile and NOT yarn install as a default both locally and on CI build servers.

NPM

  1. commit the package-lock.json.
  2. use npm ci instead of npm install when building your applications both on your CI and your local development machine