npm "Cannot read properties of null" Engine Error in CI - Fix Corrupted State
A "Cannot read properties of null" crash from the npm engine is an internal error, usually triggered by a malformed lockfile, a corrupted cache, or an npm version that mishandles your tree.
What this error means
npm install or npm ci throws a TypeError that it cannot read a property (often reading or matches) of null, with a stack trace inside npm internals rather than your code.
npm
npm ERR! Cannot read properties of null (reading 'matches')
npm ERR! A complete log of this run can be found in:
npm ERR! /home/runner/.npm/_logs/2026-06-26T00_00_00_000Z-debug.logCommon causes
A corrupted lockfile or cache
A malformed package-lock.json or a poisoned ~/.npm cache feeds null into npm internals, crashing the resolver.
An npm version mismatch with the lockfile format
An old npm reading a newer lockfileVersion (or the reverse) can hit code paths that assume data that is not present.
How to fix it
Clear state and reinstall clean
- Remove node_modules, package-lock.json, and clean the cache.
- Reinstall so npm rebuilds a consistent tree.
Terminal
rm -rf node_modules package-lock.json
npm cache clean --force
npm installAlign the npm version
- Pin a known-good npm version in CI.
- Regenerate the lockfile with that version and commit it.
Terminal
npm install -g npm@10How to prevent it
- Pin one npm version across local and CI, commit a lockfile generated by it, and cache ~/.npm keyed on the lockfile so corruption does not persist across runs.
Related guides
npm "Cannot read properties of null (reading 'matches')" - Fix the Cache Bug in CIFix the npm "Cannot read properties of null (reading 'matches')" internal error in CI - a corrupted npm cache…
npm lockfileVersion Mismatch in CI - Fix package-lock Version ConflictsFix npm lockfileVersion mismatches in CI by aligning the npm version that reads the lockfile with the version…
npm EINTEGRITY sha512 Mismatch in CI - Fix Tarball Integrity FailuresFix npm EINTEGRITY sha512 checksum mismatches in CI caused by stale lockfile hashes, a corrupted cache, or a…