question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot deploy functions using firebase-admin and ADC via firebase-tools

See original GitHub issue

I tried to upgrade Node v8 to v10. But, it occurred these errors and failed to deploy via firebase-tools version 3.8.0.

Function failed on loading user code. Error message: Warning, FIREBASE_CONFIG environment variable is missing. Initializing firebase-admin will fail
Provided module can't be loaded.
Is there a syntax error in your code?
Detailed stack trace: TypeError: Cannot read property 'token' of undefined
    at Object.<anonymous> (/srv/functions/lib/index.js:30:47)
    at Module._compile (internal/modules/cjs/loader.js:701:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:712:10)
    at Module.load (internal/modules/cjs/loader.js:600:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:539:12)
    at Function.Module._load (internal/modules/cjs/loader.js:531:3)
    at Module.require (internal/modules/cjs/loader.js:637:17)
    at require (internal/modules/cjs/helpers.js:22:18)
    at Object.getUserFunction (/srv/node_modules/@google-cloud/functions-framework/build/src/invoker.js:57:32)
    at Object.<anonymous> (/srv/node_modules/@google-cloud/functions-framework/build/src/index.js:49:33)
Could not load the function, shutting down.

I re-tried with setting FIREBASE_CONFIG, but the result did not change, and the same error was output. Here is my initialization code.

import * as admin from 'firebase-admin'
admin.initializeApp()

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:2
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
thechenkycommented, May 9, 2019

Hi @iwata thanks for the report! This is a known bug - we have a fix submitted and it should hopefully roll out next week. The reason this is happening is because Node 10 runtime was not pulling in hidden files like .runtimeconfig.json which the Firebase SDKs need to automatically set env variables like FIREBASE_CONFIG. I’d like to point out, however, that you still need to deploy with Firebase CLI in order to have that config set - otherwise you will need to initialize admin with the needed parameters (see these docs for more info).

This issue is explained in more detail in https://github.com/firebase/firebase-functions/issues/433 and https://github.com/firebase/firebase-functions/issues/432.

0reactions
iwatacommented, May 21, 2019
Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot deploy functions using firebase-admin and ADC via ...
Initializing firebase-admin will fail Provided module can't be loaded. Is there a syntax error in your code? Detailed stack trace: TypeError: ...
Read more >
Add the Firebase Admin SDK to your server - Google
The Admin SDK is a set of server libraries that lets you interact with Firebase from privileged environments to perform actions like:.
Read more >
Why doesn't Firebase admin auth in node.js use ADC?
Does anyone know why Firebase admin auth in node.js doesn't use ADC (Application Default Credentials)? I always have to set GOOGLE_APPLICATION_CREDENTIALS ...
Read more >
Can not see the Firebase function deployed - Stack Overflow
Once your cloud function have been initialized, CD into the functions folder and Redeploy it using firebase deploy --only functions .
Read more >
Firebase: Developing a Web Service with Admin SDK, Flask ...
We use Google Application Default Credentials (ADC) to authorize the Firebase API calls made by our application. ADC is the recommended ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found