Firebase-tools: Error: An unexpected error has occurred. • TypeError: Cannot read property 'wanted' of undefined

Created on 4 Jul 2019  ·  25Comments  ·  Source: firebase/firebase-tools


firebase-tools: 7.0.2


Platform: macOS


Deploying a website to firebase hosting stopped working.


firebase deploy --only hosting


Hosting successful.


Hosting fails.

[2019-07-04T15:46:39.915Z] ----------------------------------------------------------------------
[2019-07-04T15:46:39.918Z] Command: /Users/Azlan_Mac/.nvm/versions/node/v12.3.1/bin/node /Users/Azlan_Mac/.nvm/versions/node/v12.3.1/bin/firebase deploy --only hosting --debug
[2019-07-04T15:46:39.918Z] CLI Version: 7.0.2
[2019-07-04T15:46:39.918Z] Platform: darwin
[2019-07-04T15:46:39.918Z] Node Version: v12.3.1
[2019-07-04T15:46:39.919Z] Time: Thu Jul 04 2019 23:46:39 GMT+0800 (Malaysia Time)
[2019-07-04T15:46:39.919Z] ----------------------------------------------------------------------

[2019-07-04T15:46:39.928Z] > command requires scopes: ["email","openid","https://www.googleapis.com/auth/cloudplatformprojects.readonly","https://www.googleapis.com/auth/firebase","https://www.googleapis.com/auth/cloud-platform"]
[2019-07-04T15:46:39.928Z] > authorizing via signed-in user
[2019-07-04T15:46:39.929Z] [iam] checking project mydaypwaapp for permissions ["firebase.projects.get","firebasehosting.sites.update"]
[2019-07-04T15:46:39.930Z] >>> HTTP REQUEST POST https://cloudresourcemanager.googleapis.com/v1/projects/mydaypwaapp:testIamPermissions
permissions=[firebase.projects.get, firebasehosting.sites.update]
[2019-07-04T15:46:41.155Z] <<< HTTP RESPONSE 200 content-type=application/json; charset=UTF-8, vary=X-Origin, Referer, Origin,Accept-Encoding, date=Thu, 04 Jul 2019 15:46:41 GMT, server=ESF, cache-control=private, x-xss-protection=0, x-frame-options=SAMEORIGIN, x-content-type-options=nosniff, server-timing=gfet4t7; dur=1100, alt-svc=quic=":443"; ma=2592000; v="46,43,39", accept-ranges=none, transfer-encoding=chunked
[2019-07-04T15:46:41.157Z] >>> HTTP REQUEST GET https://firebase.googleapis.com/v1beta1/projects/mydaypwaapp

[2019-07-04T15:46:41.471Z] <<< HTTP RESPONSE 200 content-type=application/json; charset=UTF-8, vary=X-Origin, Referer, Origin,Accept-Encoding, date=Thu, 04 Jul 2019 15:46:41 GMT, server=ESF, cache-control=private, x-xss-protection=0, x-frame-options=SAMEORIGIN, x-content-type-options=nosniff, alt-svc=quic=":443"; ma=2592000; v="46,43,39", accept-ranges=none, transfer-encoding=chunked
[2019-07-04T15:46:42.874Z] TypeError: Cannot read property 'wanted' of undefined
at /Users/Azlan_Mac/.nvm/versions/node/v12.3.1/lib/node_modules/firebase-tools/lib/checkFirebaseSDKVersion.js:37:51
at processTicksAndRejections (internal/process/task_queues.js:89:5)

Error: An unexpected error has occurred.

bug

Most helpful comment

@prescottpure After some guidance from firebase support - we identified that npm 6.10 was causing this issue for me. Downgrading to 6.9.2 fixed it for me. Maybe that’s the same for you?

All 25 comments

This issue does not have all the information required by the template. Looks like you forgot to fill out some sections. Please update the issue with more information.

Also seeing this issue when trying to deploy cloud functions. I believe this is the line causing the issue

@prescottpure After some guidance from firebase support - we identified that npm 6.10 was causing this issue for me. Downgrading to 6.9.2 fixed it for me. Maybe that’s the same for you?

Same happens to me when deploying functions: firebase deploy --only functions

firebase-tools: 7.0.2

@mazlano27 that did the trick, thanks for posting! @brunovig you should give that a try (npm i -g [email protected])

Life saver @mazlano27

@prescottprue works for me as well. Thanks.

Thanks all for identifying the problematic line and finding a workaround!

I'll take a look at this this week, I hope. Thanks

b/137017689

It looks like the output of npm outdated firebase-functions --json=true, called here, hasn't changed between 6.9.2 and 6.10.0

6.9.2 vs 6.10.0 npm comparison

Well I guess I'm the lucky one: npm i -g [email protected] did not work for me.

@mazlano27 that did the trick, thanks for posting! @brunovig you should give that a try (npm i -g [email protected])

Thanks. This worked for me too. Looks like npm version 6.10 has some issues due to which cloud functions can not be deployed.

This has been mitigated in 7.1.0.

Getting this error for both functions and hosting deployments after upgrading to npm 6.10.1 and firebase-tools 7.2.2. So far no luck with rollbacks.

rolled back to npm 6.9.2 and it's working. Firebase -V is also 6.8.0

The fix for me was to install node/10.16.3. Also now using firebase 7.0.2.

Can we reopen this, I'm getting the problem again with:

firebase --version
7.4.0

node --version
v10.15.3

npm --version
6.11.3

yarn --version
1.15.2

The error:

npm ERR! Cannot read property '0' of undefined

npm ERR! A complete log of this run can be found in:
npm ERR!     ...2019-10-04T15_25_42_651Z-debug.log
[2019-10-04T15:25:42.753Z] TypeError: Cannot read property 'wanted' of undefined
    at ~/.nvm/versions/node/v10.15.3/lib/node_modules/firebase-tools/lib/checkFirebaseSDKVersion.js:38:51

[edit] Upgrading to node 10.16.3 (or 12) didn't work.

[edit] ... more problems:

npm install firebase-functions@latest firebase-admin@latest --save
npm ERR! Cannot read property '0' of undefined

@npomfret sorry you're having trouble. First, I see two errors there: one about property '0' and one about 'wanted'. That's suspicious to me and without more context it's hard to say which is the appropriate error.

Your logs indicate to me that you're running the firebase tool using npm (the npm ERR! strings indicate this). Do you have firebase-tools installed as a dependency of the project and are running firebase in an npm script?

Without more information, it's hard to say what's going on. I cannot replicate your issue, but it looks like the Cannot read property '0' of undefined is going to be your first thing to sort out.

I've run:

npm install -g firebase-tools

If that's what you mean?

The command I'm running to redeploy my website is:

firebase deploy --debug --only hosting

@npomfret are you running firebase deploy directly or using npm run ___ to execute it? If that's the case, the firebase-tools version in the package.json file that's installed in that folder would be the one being run, which could be causing the issue.

However, it looks like the property '0' is blocking you too, and I've not seen that error before. It may be coming from the build/parse step of the deployment. If you could share your package.json and firebase.json, that may help narrow down the cause.

I'm using the command exactly as described above: firebase deploy --debug --only hosting.

There is no package.json in this case, I'm just deploying hosting so there's only really firebase.json and a public dir with the static content in.

...solved sort of. There are some firebase functions present. I deleted them and that allowed the hosting deployment to succeed. Ugh. I hate node.

@bkendall thanks for helping

@npomfret 👍 glad you figured it out!

Guys this issue is still happening... on Hosting only no problem,, but if I added the functions to the firebase project I get the error as u see in the photo

So basically a firebase project that has both functions and hosting.. when running
firebase deploy --only hosting
I get the below error.

image

If I removed functions folder ,, it works like charm.... this thing drives me crazy..

I was having this issue too. Thanks @bdairy. Removing the functions folder worked for me too.

both firebase deploy and firebase deploy --only hosting worked after removing the /fuctions

Was this page helpful?
0 / 5 - 0 ratings