How to fix npm ERR! code ENOLOCKFILE npm ERR! No package-lock.json found in npm
This error occurs when npm commands like 'npm ci' or 'npm audit' cannot find a package-lock.json file in your project. The lock file is required to ensure reproducible installations across environments.
Quick fix
Fixes npm ERR! code ENOLOCKFILE npm ERR! No package-lock.json found
npm install- Generate the package-lock.json file locally
- Commit the package-lock.json to version control
- Verify package-lock.json is not in .gitignore
- Check and fix npm configuration settings
npm installnpm ERR! code ENOLOCKFILEnpm ERR! No package-lock.json found
npm installWhat this error means
npm ERR! code ENOLOCKFILE indicates that the package-lock.json file is missing from your project directory. This file is critical because it locks all dependency versions to ensure every environment installs identical packages. The error most commonly occurs when running npm ci (clean install) in CI/CD pipelines, which strictly requires an existing lock file. Without package-lock.json, npm cannot guarantee reproducible builds—different environments might install different dependency versions, leading to unexpected behavior or bugs.
Typical symptoms
- npm ci fails with 'ENOLOCKFILE' error in CI/CD pipelines
- Fresh clone of a repository fails during dependency installation
- npm audit command fails with missing lock file error
- Different team members have different installed versions of dependencies
- Builds work locally but fail in continuous integration environments
Common causes
- The package-lock.json file was never committed to the git repository
- package-lock.json was added to .gitignore, preventing it from being tracked
- npm configuration has package-lock set to false (via .npmrc or global config)
- The lock file was manually deleted from the project directory
- The project uses yarn as its package manager instead of npm, generating yarn.lock instead
How to fix "npm ERR! code ENOLOCKFILE npm ERR! No package-lock.json found"
Run npm install to create or update the lock file. This is the primary solution if the file never existed.
npm installThis command reads your package.json and generates a package-lock.json containing exact versions of all dependencies.
After generating the lock file, add it to git and commit. This makes the file available to other developers and CI/CD systems.
git add package-lock.json
git commit -m "Add package-lock.json"
git pushThe lock file should always be committed alongside package.json.
Check your .gitignore file to ensure package-lock.json is not being ignored:
cat .gitignore | grep package-lockIf you see package-lock.json listed in .gitignore, remove that line. The lock file is essential and should be tracked.
Verify that npm is configured to generate lock files. Check your .npmrc file and global npm settings:
cat .npmrc
npm config get package-lockIf package-lock is set to false, enable it:
npm config set package-lock trueAdvanced notes
npm ci (clean install) is the recommended command for CI/CD pipelines because it installs exactly what's in package-lock.json without modifying it. npm install, by contrast, can update package-lock.json if versions don't satisfy constraints. For production deployments, always use npm ci with an existing package-lock.json to guarantee reproducible builds. If your project uses yarn instead of npm, you'll have yarn.lock instead of package-lock.json—these are not interchangeable.
Frequently asked questions
- What does "npm ERR! code ENOLOCKFILE npm ERR! No package-lock.json found" mean?
- npm ERR! json file is missing from your project directory. This file is critical because it locks all dependency versions to ensure every environment installs identical packages.
- How do I fix "npm ERR! code ENOLOCKFILE npm ERR! No package-lock.json found"?
- This error occurs when npm commands like 'npm ci' or 'npm audit' cannot find a package-lock.json file in your project. The lock file is required to ensure reproducible installations across environments.
- What causes "npm ERR! code ENOLOCKFILE npm ERR! No package-lock.json found"?
- The package-lock.json file was never committed to the git repository package-lock.json was added to .gitignore, preventing it from being tracked npm configuration has package-lock set to false (via .npmrc or global config)
- Is the "npm ERR! code ENOLOCKFILE npm ERR! No package-lock.json found" error serious?
- Yes. This is a high-severity error that usually blocks work until it is fixed, but the steps above resolve it.
Official resources & further reading
- 📚npm Official Documentation
- 📖npm Docs: package-lock.json(Official Docs)
- 💬SO: npm install not creating package-lock.json(Stack Overflow)
- 📖npm Docs: Package Locks(Official Docs)