Cannot read property 'match' of undefined - error


(Giorgi M) #1

Hello,

user reported that he/she has problem running npm install on my repo: https://github.com/giorgi-m/online-shop

This is error log:

0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/Cellar/node/10.9.0/bin/node',
1 verbose cli   '/usr/local/bin/npm',
1 verbose cli   'install' ]
2 info using npm@6.4.1
3 info using node@v10.9.0
4 verbose npm-session 256fe389882099b1
5 silly install runPreinstallTopLevelLifecycles
6 silly preinstall online-shop@0.1.0
7 info lifecycle online-shop@0.1.0~preinstall: online-shop@0.1.0
8 silly install loadCurrentTree
9 silly install readLocalPackageData
10 timing stage:loadCurrentTree Completed in 10ms
11 silly install loadIdealTree
12 silly install cloneCurrentTreeToIdealTree
13 timing stage:loadIdealTree:cloneCurrentTree Completed in 0ms
14 silly install loadShrinkwrap
15 timing stage:rollbackFailedOptional Completed in 0ms
16 timing stage:runTopLevelLifecycles Completed in 279ms
17 silly saveTree online-shop@0.1.0
17 silly saveTree β”œβ”€β”¬ @material-ui/core@3.1.1
17 silly saveTree β”‚ β”œβ”€β”¬ @babel/runtime@7.0.0
17 silly saveTree β”‚ β”‚ └── regenerator-runtime@0.12.1
17 silly saveTree β”‚ β”œβ”€β”¬ @types/jss@9.5.6
17 silly saveTree β”‚ β”‚ β”œβ”€β”€ csstype@2.5.7
17 silly saveTree β”‚ β”‚ └── indefinite-observable@1.0.1
17 silly saveTree β”‚ β”œβ”€β”¬ @types/react-transition-group@2.0.14
17 silly saveTree β”‚ β”‚ └─┬ @types/react@16.4.14
17 silly saveTree β”‚ β”‚   └── @types/prop-types@15.5.6
17 silly saveTree β”‚ β”œβ”€β”€ brcast@3.0.1
17 silly saveTree β”‚ β”œβ”€β”€ classnames@2.2.6
17 silly saveTree β”‚ β”œβ”€β”€ csstype@2.5.7
17 silly saveTree β”‚ β”œβ”€β”€ debounce@1.2.0
17 silly saveTree β”‚ β”œβ”€β”€ deepmerge@2.1.1
17 silly saveTree β”‚ β”œβ”€β”€ dom-helpers@3.3.1
17 silly saveTree β”‚ β”œβ”€β”€ hoist-non-react-statics@2.5.5
17 silly saveTree β”‚ β”œβ”€β”¬ is-plain-object@2.0.4
17 silly saveTree β”‚ β”‚ └── isobject@3.0.1
17 silly saveTree β”‚ β”œβ”€β”¬ jss-camel-case@6.1.0
17 silly saveTree β”‚ β”‚ └── hyphenate-style-name@1.0.2
17 silly saveTree β”‚ β”œβ”€β”€ jss-default-unit@8.0.2
17 silly saveTree β”‚ β”œβ”€β”€ jss-global@3.0.0
17 silly saveTree β”‚ β”œβ”€β”¬ jss-nested@6.0.1
17 silly saveTree β”‚ β”‚ └─┬ warning@3.0.0
17 silly saveTree β”‚ β”‚   └─┬ loose-envify@1.4.0
17 silly saveTree β”‚ β”‚     └── js-tokens@4.0.0
17 silly saveTree β”‚ β”œβ”€β”€ jss-props-sort@6.0.0
17 silly saveTree β”‚ β”œβ”€β”¬ jss-vendor-prefixer@7.0.0
17 silly saveTree β”‚ β”‚ └─┬ css-vendor@0.3.8
17 silly saveTree β”‚ β”‚   └── is-in-browser@1.1.3
17 silly saveTree β”‚ β”œβ”€β”¬ jss@9.8.7
17 silly saveTree β”‚ β”‚ β”œβ”€β”€ symbol-observable@1.2.0
17 silly saveTree β”‚ β”‚ └── warning@3.0.0
17 silly saveTree β”‚ └── keycode@2.2.0
17 silly saveTree └─┬ @material-ui/icons@3.0.1
17 silly saveTree   └─┬ recompose@0.29.0
17 silly saveTree     β”œβ”€β”€ change-emitter@0.1.6
17 silly saveTree     └─┬ fbjs@0.8.17
17 silly saveTree       β”œβ”€β”€ core-js@1.2.7
17 silly saveTree       β”œβ”€β”€ isomorphic-fetch@2.2.1
17 silly saveTree       └─┬ promise@7.3.1
17 silly saveTree         └── asap@2.0.6
18 verbose stack TypeError: Cannot read property 'match' of undefined
18 verbose stack     at tarballToVersion (/usr/local/lib/node_modules/npm/lib/install/inflate-shrinkwrap.js:87:20)
18 verbose stack     at inflatableChild (/usr/local/lib/node_modules/npm/lib/install/inflate-shrinkwrap.js:99:22)
18 verbose stack     at BB.each (/usr/local/lib/node_modules/npm/lib/install/inflate-shrinkwrap.js:55:12)
18 verbose stack     at tryCatcher (/usr/local/lib/node_modules/npm/node_modules/bluebird/js/release/util.js:16:23)
18 verbose stack     at Object.gotValue (/usr/local/lib/node_modules/npm/node_modules/bluebird/js/release/reduce.js:155:18)
18 verbose stack     at Object.gotAccum (/usr/local/lib/node_modules/npm/node_modules/bluebird/js/release/reduce.js:144:25)
18 verbose stack     at Object.tryCatcher (/usr/local/lib/node_modules/npm/node_modules/bluebird/js/release/util.js:16:23)
18 verbose stack     at Promise._settlePromiseFromHandler (/usr/local/lib/node_modules/npm/node_modules/bluebird/js/release/promise.js:512:31)
18 verbose stack     at Promise._settlePromise (/usr/local/lib/node_modules/npm/node_modules/bluebird/js/release/promise.js:569:18)
18 verbose stack     at Promise._settlePromise0 (/usr/local/lib/node_modules/npm/node_modules/bluebird/js/release/promise.js:614:10)
18 verbose stack     at Promise._settlePromises (/usr/local/lib/node_modules/npm/node_modules/bluebird/js/release/promise.js:693:18)
18 verbose stack     at Async._drainQueue (/usr/local/lib/node_modules/npm/node_modules/bluebird/js/release/async.js:133:16)
18 verbose stack     at Async._drainQueues (/usr/local/lib/node_modules/npm/node_modules/bluebird/js/release/async.js:143:10)
18 verbose stack     at Immediate.Async.drainQueues [as _onImmediate] (/usr/local/lib/node_modules/npm/node_modules/bluebird/js/release/async.js:17:14)
18 verbose stack     at runCallback (timers.js:693:18)
18 verbose stack     at tryOnImmediate (timers.js:664:5)
19 verbose cwd /Users/renanromero/projects/test/react/online-shop
20 verbose Darwin 17.7.0
21 verbose argv "/usr/local/Cellar/node/10.9.0/bin/node" "/usr/local/bin/npm" "install"
22 verbose node v10.9.0
23 verbose npm  v6.4.1
24 error Cannot read property 'match' of undefined
25 verbose exit [ 1, true ]

Environment:

iMac macOS High Sierra 10.13.6
npm v6.4.1
node v10.9.0

What can be causing this and what is the solution?

PS. I remember changing something related to β€œmerge” version (e.g. set β€œmerge”: β€œ1.2.1”) in package-lock.json due to github recommendation that there was vulnerability. Could that have caused this?

Thanks.


(Lars Willighagen) #5

TL;DR: Yep, that was the cause. Deleting your package-lock.json and running npm install should fix it (and update your dependency). You can check the latter afterwards in the package-lock.json or by running:

npm ls merge

Yep, that edit has invalidated your package-lock.json for a number of reasons:

  1. Each entry should have a version key containing the version, you edited yours to be merge, which is what npm is having trouble with.
  2. The value of version shouldn’t be a range, but a version (so no >=)
  3. The value of version doesn’t match the integrity and resolved fields
  4. It’s probably better to keep the range (>=) in the first place you editted it out

(Commit for reference to others.)


(Giorgi M) #6

Hi Lars,

Thanks for the response.

I will tell you what I did now:

  1. Download project
  2. Delete package-lock.json
  3. do npm install and push back.

Is there something else I should do? (I had trouble a little bit completely following your post).

ps. strangely I don’t get that warning from github anymore about β€œmerge”


(Lars Willighagen) #7

Yes, that should work. To check if those steps actually updated the merge dependency you can check in your package-lock.json or by running npm ls merge. I think the warning on GitHub is gone for the same reason as your problem with npm: it doesn’t see merge with a version of 1.2.0, it sees no version at all.


(Giorgi M) #8

This is the output of npm ls merge:

giorgi@giorgi-pc:~/Documents/Projects/online-shop$ npm ls merge
online-shop@0.1.0 /home/giorgi/Documents/Projects/online-shop
└─┬ UNMET DEPENDENCY react-scripts@1.1.5
  └─┬ UNMET DEPENDENCY jest@20.0.4
    └─┬ UNMET DEPENDENCY jest-cli@20.0.4
      └─┬ UNMET DEPENDENCY jest-haste-map@20.0.5
        └─┬ UNMET DEPENDENCY sane@1.6.0
          └─┬ UNMET DEPENDENCY exec-sh@0.2.2
            └── UNMET DEPENDENCY merge@1.2.1

npm ERR! missing: react-scripts@1.1.5, required by online-shop@0.1.0
npm ERR! missing: jest@20.0.4, required by react-scripts@1.1.5
npm ERR! missing: jest-cli@20.0.4, required by jest@20.0.4
npm ERR! missing: jest-haste-map@20.0.5, required by jest-cli@20.0.4
npm ERR! missing: sane@1.6.0, required by jest-haste-map@20.0.5
npm ERR! missing: exec-sh@0.2.2, required by sane@1.6.0

(system) #9

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.