Operating System version: Mac OS 10.14.6
Firebase SDK version: 8.8.0
Firebase Product: database (auth, database, storage, etc)
Node.js version: v10.16.3
NPM version: 6.13.0
When I call node index.js it immediately throw
TypeError: instance.INTERNAL.registerComponent is not a function
at registerDatabase (/Users/[mypath]/scripts/node_modules/@firebase/database/index.node.ts:101:63)
at Object.<anonymous> (/Users/[mypath]/scripts/node_modules/@firebase/database/index.node.ts:146:3)
at Module._compile (internal/modules/cjs/loader.js:778:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
at Module.require (internal/modules/cjs/loader.js:692:17)
at require (internal/modules/cjs/helpers.js:25:18)
When I dive into @firebase/app/dist/index.node.cjs.js instead of registerComponent I found registerService, once I replace registerComponent to registerService it works just fine
import * as admin from 'firebase-admin';
import path = require('path');
const keyPath = process.env.FIREBASE_PATH;
const database = process.env.FIREBASE_DATABASE;
const pathToKey = path.join(__dirname, keyPath);
const serviceAccount = require(pathToKey);
admin.initializeApp({
credential: admin.credential.cert(serviceAccount),
databaseURL: database
});
getting same error since evening.
I'm also getting same error since last evening.
Take a look at this comment and the subsequent discussion: https://github.com/firebase/firebase-admin-node/issues/714#issuecomment-562699156
You probably need to upgrade @firebase/app if it's installed directly or via some other dependency.
@hiranya911 Thanks a lot
@hiranya911 thanks. that helps.
When i add @firebase/app i get a new error
Error: Failed to initialize Google Cloud Firestore client with the available credentials. Must initialize the SDK with a certificate credential or application default credentials to use Cloud Firestore API.
npm install --save firebase
then it works well.
In my case, I already had @firebase/app as part of firebase. I also have node 12 installed with Win 10
npm ls @firebase/app
functions@ C:\Users\me\source\repos\admin\functions
`-- [email protected]
`-- @firebase/[email protected]
I fixed the issue by updating the firebase dependencies to the latest.
npm i --save firebase@latest firebase-admin@latest firebase-functions@latest
From my package.json:
"firebase": "^8.2.4",
"firebase-admin": "^9.4.2",
"firebase-functions": "^3.13.1",
Note: Always update firebase-tool to the latest:
npm i -g firebase-tools@lates
Most helpful comment
Take a look at this comment and the subsequent discussion: https://github.com/firebase/firebase-admin-node/issues/714#issuecomment-562699156
You probably need to upgrade
@firebase/appif it's installed directly or via some other dependency.