Lockfile vs Version Pinning
People think a lockfile and a pinned version are the same thing, and they are not. You pin a version by hand, in the list of packages you asked for. A lockfile is written by the tool. It holds the exact version of every package, even the ones your packages pulled in. So a project can ask for ranges and still get the same install each time.
Lockfile
A file that lists the exact version of each package you use. You keep it in Git.
A lockfile is a file that lists the exact version of each package a project uses. That includes the packages those packages need. Your package manager writes it for you, like package-lock.json for npm. When someone else installs the project, they get the very same versions. You commit it to Git with the rest of your code.
Version Pinning
Asking for one set version of a package. Then it does not change by itself.
Version pinning means asking for one exact version of a package, not a range. Writing react 18.3.1 is a pin. Writing ^18.3.1 is a range, so any later 18 version may come in. A pin means nothing changes until you change it. The cost is that fixes do not arrive by themselves, so you update the pins by hand or with a bot.
In one line
- Lockfile
- A file that lists the exact version of each package you use. You keep it in Git.
- Version Pinning
- Asking for one set version of a package. Then it does not change by itself.