Hi there,
i'm a student that just starting using firebase cloud functions, currently i'm trying to deploy a function, but everytime i tried to run the function it failed to deploy! and the code doesn't seems wrong because the code could be deployed and works well in my friends PC. and yes, i've followed the suggested instructions from the console.
3.17.4
Linux
just try to deploy it return error
just running
[2018-02-24T05:05:06.665Z] ----------------------------------------------------------------------
[2018-02-24T05:05:06.672Z] Command: /usr/local/bin/node /usr/local/bin/firebase deploy --only functions --debug
[2018-02-24T05:05:06.673Z] CLI Version: 3.17.4
[2018-02-24T05:05:06.673Z] Platform: linux
[2018-02-24T05:05:06.674Z] Node Version: v9.6.1
[2018-02-24T05:05:06.674Z] Time: Sat Feb 24 2018 12:05:06 GMT+0700 (WIB)
[2018-02-24T05:05:06.674Z] ----------------------------------------------------------------------
[2018-02-24T05:05:06.696Z] > 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"]
[2018-02-24T05:05:06.696Z] > authorizing via signed-in user
[2018-02-24T05:05:06.701Z] >>> HTTP REQUEST GET https://admin.firebase.com/v1/projects/pasienia-2f867
Sat Feb 24 2018 12:05:06 GMT+0700 (WIB)
[2018-02-24T05:05:08.556Z] <<< HTTP RESPONSE 200 server=nginx, date=Sat, 24 Feb 2018 05:05:08 GMT, content-type=application/json; charset=utf-8, content-length=112, connection=close, x-content-type-options=nosniff, strict-transport-security=max-age=31536000; includeSubdomains, cache-control=no-cache, no-store
[2018-02-24T05:05:08.558Z] >>> HTTP REQUEST GET https://admin.firebase.com/v1/database/pasienia-2f867/tokens
Sat Feb 24 2018 12:05:08 GMT+0700 (WIB)
[2018-02-24T05:05:10.185Z] <<< HTTP RESPONSE 200 server=nginx, date=Sat, 24 Feb 2018 05:05:09 GMT, content-type=application/json; charset=utf-8, content-length=264, connection=close, x-content-type-options=nosniff, strict-transport-security=max-age=31536000; includeSubdomains, cache-control=no-cache, no-store
=== Deploying to 'pasienia-2f867'...
i deploying functions
[2018-02-24T05:05:11.692Z] > [functions] package.json contents: {
"name": "functions",
"description": "Cloud Functions for Firebase",
"scripts": {
"serve": "firebase serve --only functions",
"shell": "firebase experimental:functions:shell",
"start": "npm run shell",
"deploy": "firebase deploy --only functions",
"logs": "firebase functions:log"
},
"dependencies": {
"firebase-admin": "~5.4.2",
"firebase-functions": "^0.7.1"
},
"private": true
}
i functions: ensuring necessary APIs are enabled...
[2018-02-24T05:05:11.694Z] >>> HTTP REQUEST GET https://servicemanagement.googleapis.com/v1/services/cloudfunctions.googleapis.com/projectSettings/pasienia-2f867?view=CONSUMER_VIEW
Sat Feb 24 2018 12:05:11 GMT+0700 (WIB)
[2018-02-24T05:05:11.695Z] >>> HTTP REQUEST GET https://servicemanagement.googleapis.com/v1/services/runtimeconfig.googleapis.com/projectSettings/pasienia-2f867?view=CONSUMER_VIEW
Sat Feb 24 2018 12:05:11 GMT+0700 (WIB)
[2018-02-24T05:05:13.641Z] <<< HTTP RESPONSE 200 content-type=application/json; charset=UTF-8, vary=X-Origin, Referer, Origin,Accept-Encoding, date=Sat, 24 Feb 2018 05:05:13 GMT, server=ESF, cache-control=private, x-xss-protection=1; mode=block, x-frame-options=SAMEORIGIN, x-content-type-options=nosniff, alt-svc=hq=":443"; ma=2592000; quic=51303431; quic=51303339; quic=51303338; quic=51303337; quic=51303335,quic=":443"; ma=2592000; v="41,39,38,37,35", accept-ranges=none, connection=close
[2018-02-24T05:05:13.676Z] <<< HTTP RESPONSE 200 content-type=application/json; charset=UTF-8, vary=X-Origin, Referer, Origin,Accept-Encoding, date=Sat, 24 Feb 2018 05:05:13 GMT, server=ESF, cache-control=private, x-xss-protection=1; mode=block, x-frame-options=SAMEORIGIN, x-content-type-options=nosniff, alt-svc=hq=":443"; ma=2592000; quic=51303431; quic=51303339; quic=51303338; quic=51303337; quic=51303335,quic=":443"; ma=2592000; v="41,39,38,37,35", accept-ranges=none, connection=close
✔ functions: all necessary APIs are enabled
[2018-02-24T05:05:13.678Z] >>> HTTP REQUEST GET https://appengine.googleapis.com/v1/apps/pasienia-2f867
Sat Feb 24 2018 12:05:13 GMT+0700 (WIB)
[2018-02-24T05:05:13.679Z] >>> HTTP REQUEST GET https://apikeys.googleapis.com/v1/projects/pasienia-2f867/apiKeys
Sat Feb 24 2018 12:05:13 GMT+0700 (WIB)
[2018-02-24T05:05:15.527Z] <<< HTTP RESPONSE 200 content-type=application/json; charset=UTF-8, vary=X-Origin, Referer, Origin,Accept-Encoding, date=Sat, 24 Feb 2018 05:05:15 GMT, server=ESF, cache-control=private, x-xss-protection=1; mode=block, x-frame-options=SAMEORIGIN, x-content-type-options=nosniff, alt-svc=hq=":443"; ma=2592000; quic=51303431; quic=51303339; quic=51303338; quic=51303337; quic=51303335,quic=":443"; ma=2592000; v="41,39,38,37,35", accept-ranges=none, connection=close
[2018-02-24T05:05:15.533Z] <<< HTTP RESPONSE 200 content-type=application/json; charset=UTF-8, vary=X-Origin, Referer, Origin,Accept-Encoding, date=Sat, 24 Feb 2018 05:05:15 GMT, server=ESF, cache-control=private, x-xss-protection=1; mode=block, x-frame-options=SAMEORIGIN, x-content-type-options=nosniff, alt-svc=hq=":443"; ma=2592000; quic=51303431; quic=51303339; quic=51303338; quic=51303337; quic=51303335,quic=":443"; ma=2592000; v="41,39,38,37,35", accept-ranges=none, connection=close
i functions: preparing functions directory for uploading...
[2018-02-24T05:05:15.535Z] >>> HTTP REQUEST GET https://runtimeconfig.googleapis.com/v1beta1/projects/pasienia-2f867/configs
Sat Feb 24 2018 12:05:15 GMT+0700 (WIB)
[2018-02-24T05:05:16.550Z] <<< HTTP RESPONSE 200 content-type=application/json; charset=UTF-8, vary=X-Origin, Referer, Origin,Accept-Encoding, date=Sat, 24 Feb 2018 05:05:15 GMT, server=ESF, cache-control=private, x-xss-protection=1; mode=block, x-frame-options=SAMEORIGIN, x-content-type-options=nosniff, alt-svc=hq=":443"; ma=2592000; quic=51303431; quic=51303339; quic=51303338; quic=51303337; quic=51303335,quic=":443"; ma=2592000; v="41,39,38,37,35", accept-ranges=none, connection=close
[2018-02-24T05:05:16.554Z] >>> HTTP REQUEST GET https://runtimeconfig.googleapis.com/v1beta1/projects/pasienia-2f867/configs/someservice/variables
Sat Feb 24 2018 12:05:16 GMT+0700 (WIB)
[2018-02-24T05:05:17.130Z] <<< HTTP RESPONSE 200 content-type=application/json; charset=UTF-8, vary=X-Origin, Referer, Origin,Accept-Encoding, date=Sat, 24 Feb 2018 05:05:16 GMT, server=ESF, cache-control=private, x-xss-protection=1; mode=block, x-frame-options=SAMEORIGIN, x-content-type-options=nosniff, alt-svc=hq=":443"; ma=2592000; quic=51303431; quic=51303339; quic=51303338; quic=51303337; quic=51303335,quic=":443"; ma=2592000; v="41,39,38,37,35", accept-ranges=none, connection=close
[2018-02-24T05:05:17.133Z] >>> HTTP REQUEST GET https://runtimeconfig.googleapis.com/v1beta1/projects/pasienia-2f867/configs/someservice/variables/id
Sat Feb 24 2018 12:05:17 GMT+0700 (WIB)
[2018-02-24T05:05:17.135Z] >>> HTTP REQUEST GET https://runtimeconfig.googleapis.com/v1beta1/projects/pasienia-2f867/configs/someservice/variables/key
Sat Feb 24 2018 12:05:17 GMT+0700 (WIB)
[2018-02-24T05:05:17.759Z] <<< HTTP RESPONSE 200 content-type=application/json; charset=UTF-8, vary=X-Origin, Referer, Origin,Accept-Encoding, date=Sat, 24 Feb 2018 05:05:17 GMT, server=ESF, cache-control=private, x-xss-protection=1; mode=block, x-frame-options=SAMEORIGIN, x-content-type-options=nosniff, alt-svc=hq=":443"; ma=2592000; quic=51303431; quic=51303339; quic=51303338; quic=51303337; quic=51303335,quic=":443"; ma=2592000; v="41,39,38,37,35", accept-ranges=none, connection=close
[2018-02-24T05:05:17.763Z] <<< HTTP RESPONSE 200 content-type=application/json; charset=UTF-8, vary=X-Origin, Referer, Origin,Accept-Encoding, date=Sat, 24 Feb 2018 05:05:17 GMT, server=ESF, cache-control=private, x-xss-protection=1; mode=block, x-frame-options=SAMEORIGIN, x-content-type-options=nosniff, alt-svc=hq=":443"; ma=2592000; quic=51303431; quic=51303339; quic=51303338; quic=51303337; quic=51303335,quic=":443"; ma=2592000; v="41,39,38,37,35", accept-ranges=none, connection=close
Error: Error occurred while parsing your function triggers. Please ensure you have the latest firebase-functions SDK by running "npm i --save firebase-functions@latest" inside your functions folder.
Error: Firebase config variables are not available. Please use the latest version of the Firebase CLI to deploy this function.
at init (/home/muhwyndham/Documents/AndroidProjects/Pasienia/firebase-web/functions/node_modules/firebase-functions/lib/config.js:51:15)
at Object.config (/home/muhwyndham/Documents/AndroidProjects/Pasienia/firebase-web/functions/node_modules/firebase-functions/lib/config.js:29:9)
at Object.
at Module._compile (module.js:662:30)
at Object.Module._extensions..js (module.js:673:10)
at Module.load (module.js:575:32)
at tryModuleLoad (module.js:515:12)
at Function.Module._load (module.js:507:3)
at Module.require (module.js:606:17)
at require (internal/module.js:11:18)
What is your repository structure? Is node_modules inside of firebase-web/functions? And what does your functions/package.json look like?
This is happening to me, too. firebase deploy worked this morning. And now it fails with the above error (except i'm on Windows).
@davidmurdoch Can you answer my questions above?
It was user error on my part. I _did_ run npm i --save firebase-functions@latest, but not from the functions folder as the CLI error instructed. :-D
I'm having a similar issue. I'm creating config variables with firebase functions:config:set some.thing="etc" and then those variables are not available when doing firebase functions:config:get.
Of course my functions are not being deployed and I get the error TypeError: Cannot read property 'thing' of undefined.
@PierBover Can you file a separate issue with log outputs from running both the set and get commands with the --debug flag?
@laurenzlong @PierBover was a separate issue opened for this? I'm getting it too, and looking for if the issue was opened
I am having a similar issue. I have set the variables with firebase functions:config:set. If I get them with functions:config:get it is printed out as it should be but in serve if I call config() the variable I have set is undefined.
@tomas-paronai
You need to run this in the functions directory:
firebase functions:config:get > .runtimeconfig.json
However, if you're using Windows PowerShell, replace the above command with:
firebase functions:config:get | ac .runtimeconfig.json
See https://firebase.google.com/docs/functions/local-emulator
@laurenzlong Thank you for pointing me to the right spot. It did the job. I had to miss this in docs.
Most helpful comment
@tomas-paronai
You need to run this in the functions directory:
firebase functions:config:get > .runtimeconfig.jsonHowever, if you're using Windows PowerShell, replace the above command with:
firebase functions:config:get | ac .runtimeconfig.jsonSee https://firebase.google.com/docs/functions/local-emulator