Reputation: 1555
With the following code:
const functions = require('firebase-functions')
const admin = require('firebase-admin')
admin.initializeApp()
exports.onTest = functions.https.onRequest(async (req, res) => {
res.json({ msg: 'done' })
})
which comes exactly from the example docs, ... running firebase emulators:start
from cli generates the following error:
⚠ TypeError: instance.registerVersion is not a function
at registerDatabase (/Users/<path>/functions/node_modules/@firebase/database/dist/index.node.cjs.js:15188:14)
at Object.<anonymous> (/Users/<path>/functions/node_modules/@firebase/database/dist/index.node.cjs.js:15200:5)
at Module._compile (module.js:653:30)
at Object.Module._extensions..js (module.js:664:10)
at Module.load (module.js:566:32)
at tryModuleLoad (module.js:506:12)
at Function.Module._load (module.js:498:3)
at Module.require (module.js:597:17)
at require (internal/module.js:11:18)
at FirebaseNamespace.get [as database] (/Users/tremendus/Development/kulanu/playground/kulanu-cloud/functions/node_modules/firebase-admin/lib/firebase-namespace.js:282:38)
⚠ We were unable to load your functions code. (see above)
Several other examples on SO and other sites call #initializeApp
with initializeApp(functions.config().firebase)
... but this also throws the same error.
I'm using node 8 functions and node 8 locally and basic pacakage.json dependencies:
"dependencies": {
"firebase-admin": "^8.6.0",
"firebase-functions": "^3.3.0"
}
UPDATE: although the command firebase emulators:start
throws the above error, the functions work in shell:
MacPro:functions: firebase functions:shell
✔ functions: Emulator started at http://localhost:5000
> function: apiOnSave
i functions: Loaded functions: apiOnSave
firebase > apiOnSave()
Sent request to function.
firebase > > function: apiOnSave
RESPONSE RECEIVED FROM FUNCTION: 200, {
"msg": "done"
}
Doesn't anyone have suggestions on how to resolve this?
Upvotes: 5
Views: 786
Reputation: 24508
Seems to be a bug in [email protected]
. Going back to [email protected]
fixes it for me.
Since for me, firebase
is a direct dependency, this does the trick:
npm i -S [email protected] --force
However in your case, it is an indirect dependency -- Try to find out which version your installation uses with:
npm list firebase
Try going back to a version of firebase-admin
and firebase-functions
that uses an earlier version of firebase
.
Upvotes: 2