diff --git a/.changeset/tall-bikes-own.md b/.changeset/tall-bikes-own.md new file mode 100644 index 00000000000..009e298c3c0 --- /dev/null +++ b/.changeset/tall-bikes-own.md @@ -0,0 +1,5 @@ +--- +"@firebase/database": patch +--- + +Fixes an internal conflict when using v8 and v9 SDKs in the same package. diff --git a/packages/database/index.node.ts b/packages/database/index.node.ts index 277365da490..5388bd2d102 100644 --- a/packages/database/index.node.ts +++ b/packages/database/index.node.ts @@ -123,8 +123,10 @@ try { // @firebase/app when used together with the js sdk. More detail: // https://github.com/firebase/firebase-js-sdk/issues/1696#issuecomment-501546596 // eslint-disable-next-line import/no-extraneous-dependencies, @typescript-eslint/no-require-imports - const firebase = require('@firebase/app').default; - registerDatabase(firebase); + const firebase = require('@firebase/app').default; // Only present for v8, undefined for v9 (should skip). + if (firebase) { + registerDatabase(firebase); + } } catch (err) { // catch and ignore 'MODULE_NOT_FOUND' error in firebase-admin context // we can safely ignore this error because RTDB in firebase-admin works without @firebase/app