TypeError: Cannot read property 'INTERNAL' of undefined at FirebaseNamespace.initializeApp
See original GitHub issue[REQUIRED] Step 2: Describe your environment
- Operating System version: macOS 10.14.4 (18E226)
- Firebase SDK version: 8.2.0
- Library version: unclear what this means
- Firebase Product: initialization of admin app
[REQUIRED] Step 3: Describe the problem
Steps to reproduce:
Clone the following repository: https://github.com/liamdanielduffy/firebase-admin-bug-repro
Run npm install
or yarn
in the repository root.
Run npm run dev
or yarn dev
to start the server.
Visit localhost:3000/api/graphql
.
See the following message printed in the server logs:
TypeError: Cannot read property 'INTERNAL' of undefined
at FirebaseNamespace.initializeApp (.../firebase-admin-bug-repro/node_modules/firebase-admin/lib/firebase-namespace.js:392:21)
...(rest of stack trace)
Further context
The firebase admin SDK is being initialized in libraries/firebase/initializeAdminApp
.
The service account key is present in the repository, and is exported from libraries/firebase/getKey
.
On each network request to localhost:3000/api/graphql
, the function defined in libraries/apollo/getContext
is called. This function attempts to pass the firebase app as part of the ‘context’ for all the graphql resolvers defined in libraries/nexus/schema
.
I’m not sure why the error is being printed above, but the stack trace above points to this line in the firebase-admin
package: firebase-admin/lib/firebase-namespace.js:392
FirebaseNamespace.prototype.initializeApp = function (options, appName) {
return this.INTERNAL.initializeApp(options, appName);
};
this
is undefined, creating the error thrown.
Why would that happen? Am I initializing this in the wrong way or in the wrong place?
Issue Analytics
- State:
- Created 4 years ago
- Reactions:8
- Comments:17 (2 by maintainers)
Now gives me this error (used to work). While the following now works
Just in case anyone else comes across this issue, make sure you import looks this
not this
If it is like ^ Typescript won’t throw an error but firebase will throw an error at runtime.