npm Community Forum (Archive)

The npm community forum has been discontinued.

To discuss usage of npm, visit the GitHub Support Community.

Cannot read property 'match' of undefined

What I Wanted to Do

npm it to get my local install of modular-css up-to-date.


What Happened Instead

C:\Users\tivac\Documents\modular-css>npm it
npm ERR! Cannot read property 'match' of undefined

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\tivac\AppData\Roaming\npm-cache\_logs\2018-06-06T16_16_57_256Z-debug.log

Reproduction Steps

  1. Grab
  2. npm it
  3. See the error



C:\Users\tivac\Documents\modular-css>npm --versions
{ 'modular-css-root': '0.0.0',
  npm: '6.1.0',
  ares: '1.10.1-DEV',
  cldr: '32.0',
  http_parser: '2.8.0',
  icu: '60.1',
  modules: '57',
  napi: '3',
  nghttp2: '1.29.0',
  node: '8.11.2',
  openssl: '1.0.2o',
  tz: '2017c',
  unicode: '10.0',
  uv: '1.19.1',
  v8: '6.2.414.54',
  zlib: '1.2.11' }

Full npm debug log.

Couple of extra data points:

  1. I get the same error w/ a bare npm install
  2. If I delete package-lock.json the install will succeed w/o issue.

I can work around this for now by deleting my lockfile before every install and/or disabling the lockfile via config, but neither of those are really good choices.

  1. $ rm -rf package-lock.json node_modules <-- you need both
  2. $ npm install
  3. And you should be back up and running (at least, I can no longer repro it).

It looks like you have a weird/bad entry in the pkglock. I have no idea why the version disappeared from your package-lock.json, but this is probably why you’re getting this error:

"clap": {
  "bundled": true

Your package-lock.json is actually really messed up for some reason. It’s not just the above entry, and I don’t see an obvious way to have npm auto-repair this sort of thing. It’s broken enough that I don’t think it’s even worth adding such a patch. (/cc @iarna in case she thinks otherwise!) It might have to do with bundledDeps, plus your node_modules having gotten bad metadata in the process.

Let me know if the above doesn’t actually fix it for you. At the very least, you should be able to get back to work. :slight_smile: And please let me know if you figure out how your pkglock even got like that. (and if this works for you, remember to mark this post as the solution!)

One thing I wonder about is whether it was because of treating it as binary, but I’ve no idea why that’d break it.

Thanks for taking a look @zkat!

Your fix definitely sorted it. Embarassed that I never thought to try deleting both the lockfile and node_modules, but oh well.

I’ve gone through various permutations of having a lock/vs not having a lock as well as using beta builds of lerna so it’s not all that surprising that it got horked up by something at some point. I’m just glad to be back up & running again!

I just reported a similar problem in the SR causing npm i to fail.
I can remove the lock file and run npm i successfully and then it fails again.

@doberkofler You only mention removing the lock-file, but the directions here are to remove the lock-file AND the node_modules. Have you tried it with both?

@iarna Removing the lock file AND the node_modules folder worked for me. Only removing the lock file only worked once.