This error occurs when running npm ci without a package-lock.json file. Generate the lockfile with npm install and commit it to version control.
npm ci (clean install) is designed for continuous integration environments where reproducible builds are essential. It requires package-lock.json to exist because it installs exactly the versions specified in the lockfile. Without a lockfile, npm ci cannot guarantee reproducible builds - different runs might install different versions of transitive dependencies, potentially causing subtle bugs. This error usually means package-lock.json is either missing from the repository or excluded by .gitignore.
Create package-lock.json:
npm installThis generates package-lock.json based on your package.json.
Ensure package-lock.json is NOT in .gitignore:
grep "package-lock" .gitignoreIf found, remove the line. The lockfile SHOULD be committed.
# Remove from .gitignore if present
sed -i '/package-lock/d' .gitignoreAdd and commit:
git add package-lock.json
git commit -m "Add package-lock.json for reproducible builds"
git pushWhy commit package-lock.json?
1. Reproducibility: Everyone gets identical dependency trees
2. Security: Lockfile captures audited versions
3. Speed: npm ci is faster than npm install
4. Debugging: You can see exactly what changed between commits
For libraries (packages you publish to npm), some teams prefer not to commit lockfiles since consumers use their own resolution. But for applications, always commit it.
If you're using yarn instead of npm, commit yarn.lock:
git add yarn.lockIf you're using pnpm, commit pnpm-lock.yaml:
git add pnpm-lock.yamlFor monorepos, ensure the lockfile is at the root and covers all workspaces.
npm ERR! code E401 npm ERR! 401 Unauthorized - Token has expired
Token has expired - npm authentication failure
npm ERR! code ENOAUDIT npm ERR! Audit endpoint not supported
How to fix "npm ERR! code ENOAUDIT - Audit endpoint not supported"
npm ERR! code EBADDEVENGINES npm ERR! devEngines.runtime incompatible with current node version
How to fix "npm ERR! code EBADDEVENGINES - devEngines.runtime incompatible with current node version"
Your CI pipeline should now work:
# Example GitHub Actions
- name: Install dependencies
run: npm cinpm ci will use the committed lockfile for reproducible installs.