Issue
Running an npm command, such as npm install
or npm ci
, may raise something like this:
npm err TypeError: Cannot read property 'match' of undefined
and break the script that is running.
Resolution
This is a known version bug in NPM. Right now, the best way to resolve is to regenerate the package-lock.json
until there is a fix for the cause.
-
Remove the
node_modules
andpackage-lock.json
(ornpm-shrinkwrap.json
, if that is what is being used). (rm package-lock.json && rm -rf node_modules
) -
Check the local versions of Node and npm.
node -v
npm -v
-
If the Node and npm versions locally don't match the
"engines"
in thepackage.json
, install the versions that match thepackage.json
. For information on installing Node and npm locally, visit the Node docs: https://nodejs.org/en/download/ -
Regenerate the
package-lock.json
. Do this by runningnpm install
. Thenode_modules
will also be regenerated.