npm ERR! Cannot read properties of null (reading 'pickAlgorithm') — how to fix
npm ERR! Cannot read properties of null (reading 'pickAlgorithm')
npm ERR! A complete log of this run can be found in:
npm ERR! /home/me/.npm/_logs/2026-11-29T10_12_44_123Z-debug-0.log
Quick fix: Clear the cache and reinstall: npm cache clean --force, then rm -rf node_modules package-lock.json and npm install. If it persists, update npm (npm install -g npm@latest) and check that no other npm process or a proxy is corrupting downloads.
What it means
pickAlgorithm is a function in ssri, the library npm uses to verify the integrity hashes (sha512-...) of downloaded packages. The error means npm expected integrity data for a package and got null, then crashed. In practice this almost always comes from npm's local cache (~/.npm/_cacache) being in an inconsistent state, or from a lockfile/node_modules combination npm can't reconcile.
Fix 1: clean the cache
npm cache clean --force
npm install
On Windows (PowerShell) the same commands work. The cache lives in %LocalAppData%\npm-cache.
To check the cache without deleting it:
npm cache verify
Fix 2: reinstall from scratch
If cleaning the cache alone doesn't help, remove the installed tree and lockfile and let npm resolve again:
rm -rf node_modules package-lock.json
npm cache clean --force
npm install
PowerShell:
Remove-Item -Recurse -Force node_modules, package-lock.json
npm cache clean --force
npm install
Deleting package-lock.json can upgrade dependencies within the ranges in package.json. Commit the new lockfile and run your tests. If you need to keep the exact versions, try first with only node_modules removed and the lockfile kept, then npm ci.
Fix 3: update npm
Older npm versions crash on some cache and lockfile states that newer ones handle. Update npm (or Node, which ships with npm):
npm -v
npm install -g npm@latest
Note that npm@latest may require a newer Node; if the install complains, upgrade Node to a current LTS first.
Fix 4: mixed package managers or lockfile versions
A project with both yarn.lock/pnpm-lock.yaml and package-lock.json, or a lockfile created by a much newer npm than the one you're running, can trip npm up. Use one package manager per project, delete the other lockfiles, and make sure the whole team and CI use similar npm versions (an engines field or .nvmrc helps).
Fix 5: something corrupts downloads
If the error comes back after a clean install:
- A corporate proxy or antivirus that rewrites downloads can break integrity data. Check
npm config get registryandnpm config get proxy. - Two npm processes writing the same cache at once (for example parallel CI jobs sharing
~/.npm) can corrupt it. Give each job its own cache or usenpm ci. - A full disk leaves half-written cache entries. Check with
df -h.
Read the debug log
The last lines of the log file named in the error show which package npm was processing when it crashed:
tail -n 50 ~/.npm/_logs/*-debug-0.log
If one specific package keeps failing, try installing it alone (npm install <pkg>) to confirm.
Last updated 2026-11-29.