TypeError: Cannot read property 'wanted' of undefined:

This just started happening to me also...

Looks like either npm is outputting a different result for this command

npm outdated firebase-functions --json=true
// for me outputs  {}\n

And the script checkFirebaseSDKVersion.js is expecting something like this (which it would get if your firebase-functions WAS actually out of date)

{
  "current": "2.5.0",
  "wanted": "2.5.0",
  "latest": "3.0.2",
  "location": "node_modules/some path /firebase-functions"
}

OR a blank output... more likely in your case

What you can do to 'Fix' it

This will probably get fixed pretty soon as it start affecting more people... for now modify /usr/local/lib/node_modules/firebase-tools/lib/checkFirebaseSDKVersion.js

add this to account for the updated empty output of {}\n around line 24

            if (data && data.toString() !== "{}\n") {
                output = JSON.parse(data.toString("utf8")); // existing Code!
            }

Not sure how the update process works for npm, so you might have to revert this to update it when fixed, but I don't think so.

Hope that helps!


I think this issue is caused by a fix in npm 6.10.0, see https://github.com/npm/cli/pull/176.

A workaround is to modify /usr/lib/node_modules/firebase-tools/lib/checkFirebaseSDKVersion.js (linux). For macOS and nvm, see comments below.

from:

if (!output) {
  return;
}

to:

if (!output || !output["firebase-functions"]) {
  return;
}

Had the exact same problem, started right after updating npm from 6.9.2 to 6.10.0.

Ended up downgrading back to 6.9.2 (npm install -g [email protected]), and my firebase deploys started working again, right away.

Edit : firebase deploys are working with npm 6.10.1, safe to update now!