TypeError: Cannot read property 'wanted' of undefined:

前端 未结 5 2474
面向向阳花
面向向阳花 2021-02-12 09:22

I have been deploying functions with firebase successfully all day learning how to use it. I was trying to see what happened if I initialized another directory that deploys to t

5条回答
  •  野的像风
    2021-02-12 10:24

    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!

提交回复
热议问题