npm ERR! Cannot read property ‘match’ of undefined error handling

Issue

When I’m trying to npm install my Nest.js repository, I get this error :

npm ERR! Cannot read properties of null (reading 'matches')

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/twalterspieler/.npm/_logs/2022-06-03T21_28_12_401Z-debug-0.log

Any idea on how to solve that ?

Solution

In general, this error occurs when there is no package-lock.json.
To fix that you need to force clear your npm cache :

npm cache clear --force

Sometime it’s enough. But if the error persists, remove node_modules:

rm -rf node_modules

Then re-clear the npm cache :

npm cache clear --force

Then re-install :

npm install

Answered By – Thibault Walterspieler

Answer Checked By – Candace Johnson (AngularFixing Volunteer)

Leave a Reply

Your email address will not be published.