Cli: [BUG] TypeError: Cannot read property 'match' of undefined

Created on 4 Mar 2020  ·  3Comments  ·  Source: npm/cli

What / Why

Angular 9.0.2
NodeJS: 13.9.0
npm: 6.13.7

When

  • Whenever I install an npm package with an existing package-lock.json
  • After typing git push heroku master

Where

  • https://github.com/theADAMJR/kittenoverflow -> source of bug

How

  • https://pastebin.com/rB36VJGu -> log of error

Current Behavior

  • Failure to deploy on Heroku (most of the time)

Steps to Reproduce

  • Install any npm package with package-lock.json (using this project)

Expected Behavior

  • TypeError: Cannot read property 'match' of undefined

Who

  • Me

References

  • n/a

Most helpful comment

Found the culprit. Somehow, the lockfile had a malformed dependency saved. Looked like:

"rc": {}

After removing that, npm install worked once again.

I believe it was an npm audit fix that was run just prior to that, but will try to keep better track of which exact step produced this.

All 3 comments

Here's some logs for this error that might help:

19 verbose stack TypeError: Cannot read property 'match' of undefined
19 verbose stack     at tarballToVersion (/home/jpage/.nvm/versions/node/v12.16.1/lib/node_modules/npm/lib/install/inflate-shrinkwrap.js:87:20)
19 verbose stack     at inflatableChild (/home/jpage/.nvm/versions/node/v12.16.1/lib/node_modules/npm/lib/install/inflate-shrinkwrap.js:99:22)
19 verbose stack     at /home/jpage/.nvm/versions/node/v12.16.1/lib/node_modules/npm/lib/install/inflate-shrinkwrap.js:55:12
19 verbose stack     at tryCatcher (/home/jpage/.nvm/versions/node/v12.16.1/lib/node_modules/npm/node_modules/bluebird/js/release/util.js:16:23)
19 verbose stack     at Object.gotValue (/home/jpage/.nvm/versions/node/v12.16.1/lib/node_modules/npm/node_modules/bluebird/js/release/reduce.js:155:18)
19 verbose stack     at Object.gotAccum (/home/jpage/.nvm/versions/node/v12.16.1/lib/node_modules/npm/node_modules/bluebird/js/release/reduce.js:144:25)
19 verbose stack     at Object.tryCatcher (/home/jpage/.nvm/versions/node/v12.16.1/lib/node_modules/npm/node_modules/bluebird/js/release/util.js:16:23)
19 verbose stack     at Promise._settlePromiseFromHandler (/home/jpage/.nvm/versions/node/v12.16.1/lib/node_modules/npm/node_modules/bluebird/js/release/promise.js:517:31)
19 verbose stack     at Promise._settlePromise (/home/jpage/.nvm/versions/node/v12.16.1/lib/node_modules/npm/node_modules/bluebird/js/release/promise.js:574:18)
19 verbose stack     at Promise._settlePromise0 (/home/jpage/.nvm/versions/node/v12.16.1/lib/node_modules/npm/node_modules/bluebird/js/release/promise.js:619:10)
19 verbose stack     at Promise._settlePromises (/home/jpage/.nvm/versions/node/v12.16.1/lib/node_modules/npm/node_modules/bluebird/js/release/promise.js:699:18)
19 verbose stack     at _drainQueueStep (/home/jpage/.nvm/versions/node/v12.16.1/lib/node_modules/npm/node_modules/bluebird/js/release/async.js:138:12)
19 verbose stack     at _drainQueue (/home/jpage/.nvm/versions/node/v12.16.1/lib/node_modules/npm/node_modules/bluebird/js/release/async.js:131:9)
19 verbose stack     at Async._drainQueues (/home/jpage/.nvm/versions/node/v12.16.1/lib/node_modules/npm/node_modules/bluebird/js/release/async.js:147:5)
19 verbose stack     at Immediate.Async.drainQueues [as _onImmediate] (/home/jpage/.nvm/versions/node/v12.16.1/lib/node_modules/npm/node_modules/bluebird/js/release/async.js:17:14)
19 verbose stack     at processImmediate (internal/timers.js:456:21)
20 verbose cwd /home/jpage/Code/vnext-api
21 verbose Linux 4.4.0-18362-Microsoft
22 verbose argv "/home/jpage/.nvm/versions/node/v12.16.1/bin/node" "/home/jpage/.nvm/versions/node/v12.16.1/bin/npm" "audit" "fix"
23 verbose node v12.16.1
24 verbose npm  v6.14.2
25 error Cannot read property 'match' of undefined
26 verbose exit [ 1, true ]

From that stack, it looks like the problem is that sw.version is undefined here:

https://github.com/npm/cli/blob/latest/lib/install/inflate-shrinkwrap.js#L99

Found the culprit. Somehow, the lockfile had a malformed dependency saved. Looked like:

"rc": {}

After removing that, npm install worked once again.

I believe it was an npm audit fix that was run just prior to that, but will try to keep better track of which exact step produced this.

Was this page helpful?
0 / 5 - 0 ratings