Use lockfiles
Commit a lockfile and install from it. A lockfile records the exact version and artifact hash of every dependency, so every install gets the same bytes, and a replaced artifact fails the install instead of running.
Why lock
#- The same install everywhere. A laptop, CI, and a release build resolve the same versions. Without a lockfile, each install resolves again and can pick a newer version.
- Replaced artifacts fail. A registry can replace both a package and its advertised hash. The hash you committed lets your client catch that later substitution.
- Minimum Age Policy works as intended. A version enters your build only when you refresh the lock, and your Feed withholds versions younger than its Minimum Age, 24 hours by default. Without a lockfile, a version arrives in the next CI run the moment its hold ends, without anyone reviewing it.
- Dependency changes are reviewable. A lockfile diff in a pull request shows every version that changes.
A lockfile protects installs of what you already locked. New resolution still trusts the source used when you refresh the lock, which is why that source should be your Feed.
When not locking is fine
#Almost never. Two cases:
- A throwaway script or experiment that nothing else installs.
- A library's published dependency ranges. Consumers resolve those against their own lockfile, so keep ranges in the manifest. Still lock the library's own development and CI installs.
With your agent
#"Commit a lockfile for this project and make CI install from it."
Lock each client
#Create the lockfile once through your Feed and commit it. In CI, install with the command that refuses to change the lockfile.
npm
#npm install # writes package-lock.json
npm ci # CIpnpm
#pnpm install # writes pnpm-lock.yaml
pnpm install --frozen-lockfile # CIYarn
#yarn install # writes yarn.lock
yarn install --immutable # CI, Yarn modern
yarn install --frozen-lockfile # CI, Yarn ClassicBun
#bun install # writes bun.lock
test -f bun.lock && bun install --frozen-lockfile # CIuv
#uv lock # writes uv.lock
uv sync --locked # CIPoetry
#poetry lock # writes poetry.lock
test -f poetry.lock && poetry check --lock && poetry sync # CI, Poetry 2PDM
#pdm lock # writes pdm.lock
pdm install --check # CIpip
#pip has no lockfile, and it checks hashes only for requirements that carry them. Prefer uv. To stay on pip, generate a fully pinned requirements file with hashes and install it in hash-checking mode.
# requirements.in lists your direct dependencies, unpinned
uv pip compile --generate-hashes requirements.in -o requirements.txt
# or, with pip-tools:
pip-compile --generate-hashes requirements.in
pip install --require-hashes -r requirements.txt # CI