Lockfile Examples
- npm:
package-lock.json
ornpm-shrinkwrap.json
- Yarn:
yarn.lock
- PNPM:
pnpm-lock.yaml
,pnpm-lock.yml
- Bun:
bun.lock
,bun.lockb
- Deno:
deno.lock
Why You Should Use Lockfiles
Using a lockfile is critical for secure and predictable builds. A lockfile contains a fixed version and a hash for each dependency and sub-dependency in your project.- Supply Chain Protection
Lockfiles prevent malicious package injections. This is crucial as supply chain attacks are rising. - Predictable Builds
Everyone uses the exact same package versions, avoiding “it works on my machine” inconsistencies. - Performance Gains
With dependency versions locked, build tools skip the usual resolution step, making builds faster.
Lockfiles are never edited manually. They’re generated and updated by your package manager and committed to your repository, ensuring consistent environments for all teammates.
Recommended Steps
- Install Dependencies
e.g.,npm install
,yarn install
,pnpm install
, orbun install
. - Commit the Generated Lockfile
This ensures your entire dev team and CybeDefend use identical dependencies. - Avoid Manual Edits
Let the package manager handle the lockfile; do not modify it by hand.
Deno Projects
For Deno projects, you can generate a lockfile with:Supported Files for Node
File Examples |
---|
npm-shrinkwrap.json , yarn.lock , pnpm-lock.yaml , bun.lock , bun.lockb , deno.lock , libman.json , package.json , package-lock.json |
Pin or lock versions in dependencies rather than devDependencies if you want to ensure full coverage for production packages.