How to fix npm ERR! code ENOLOCKFILE npm ERR! No package-lock.json found in npm

npmBEGINNERHIGHUpdated Dec 5, 2025· 113 views

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
  1. Generate the package-lock.json file locally
  2. Commit the package-lock.json to version control
  3. Verify package-lock.json is not in .gitignore
  4. Check and fix npm configuration settings
npm — error
npm install
npm ERR! code ENOLOCKFILE
npm ERR! No package-lock.json found
shell
npm install

What 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

  1. The package-lock.json file was never committed to the git repository
  2. package-lock.json was added to .gitignore, preventing it from being tracked
  3. npm configuration has package-lock set to false (via .npmrc or global config)
  4. The lock file was manually deleted from the project directory
  5. 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"

1Generate the package-lock.json file locally

Run npm install to create or update the lock file. This is the primary solution if the file never existed.

bash
npm install

This command reads your package.json and generates a package-lock.json containing exact versions of all dependencies.

2Commit the package-lock.json to version control

After generating the lock file, add it to git and commit. This makes the file available to other developers and CI/CD systems.

bash
git add package-lock.json
git commit -m "Add package-lock.json"
git push

The lock file should always be committed alongside package.json.

3Verify package-lock.json is not in .gitignore

Check your .gitignore file to ensure package-lock.json is not being ignored:

bash
cat .gitignore | grep package-lock

If you see package-lock.json listed in .gitignore, remove that line. The lock file is essential and should be tracked.

4Check and fix npm configuration settings

Verify that npm is configured to generate lock files. Check your .npmrc file and global npm settings:

bash
cat .npmrc
npm config get package-lock

If package-lock is set to false, enable it:

bash
npm config set package-lock true

Advanced 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