Cannot read property .match of undefined

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.

  1. Remove the node_modules and package-lock.json (or npm-shrinkwrap.json, if that is what is being used). (rm package-lock.json && rm -rf node_modules)

  2. Check the local versions of Node and npm.

node -v
npm -v
  1. If the Node and npm versions locally don't match the "engines" in the package.json, install the versions that match the package.json. For information on installing Node and npm locally, visit the Node docs: https://nodejs.org/en/download/

  2. Regenerate the package-lock.json. Do this by running npm install. The node_modules will also be regenerated.

Ask on Stack Overflow

Engage with a community of passionate experts to get the answers you need

Ask on Stack Overflow

Heroku Support

Create a support ticket and our support experts will get back to you

Contact Heroku Support