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.lockto the repository and commit it
- Use yarn install --frozen-lockfileand NOTyarn installas a default both locally and on CI build servers.
NPM
- commit the package-lock.json.
- use npm ciinstead ofnpm installwhen building your applications both on your CI and your local development machine