Angularfire: Electron - This is a browser-targeted Firebase bundle but it appears it is being run in a Node environment

Created on 19 Apr 2019  路  18Comments  路  Source: angular/angularfire

Version info

Angular: 7.2.1

Firebase: 5.9.1

AngularFire: 5.1.0

Other (e.g. Ionic/Cordova, Node, browser, operating system): Electron 2.0.14

How to reproduce these conditions

Steps to set up and reproduce

  1. Create a sample angular application with firebase.
  2. Include this angular app inside an electron build (you can see an example main.js file here: https://github.com/Supamiu/ffxiv-teamcraft/blob/staging/desktop/main.js, which is the repository of the code producing the error)
  3. Build the electron app and start it.
  4. Open the console to notice the warning message.

Sample data and security rules

N/A

Debug output

* Errors in the JavaScript console *

Warning: This is a browser-targeted Firebase bundle but it appears it is being
run in a Node environment. If running in a Node environment, make sure you
are using the bundle specified by the "main" field in package.json.

If you are using Webpack, you can specify "main" as the first item in
"resolve.mainFields":
https://webpack.js.org/configuration/resolve/#resolvemainfields

If using Rollup, use the rollup-plugin-node-resolve plugin and set "module"
to false and "main" to true:
https://github.com/rollup/rollup-plugin-node-resolve

* Output from firebase.database().enableLogging(true); *

N/A

* Screenshots *

N/A

Expected behavior

Firebase should work fine inside electron.

Actual behavior

It seems like this warning also produces some connection issues with but I couldn't confirm it yet.

Most helpful comment

I solved issue with my ssr setup by making firebase depenencies "external" in firebase config for server bunding. Just add: externals: [/^firebase/] to your webpack config, and make sure that all dependencies are installed in functions folder (package).

All 18 comments

any updates on this?

In my case, it's giving a warning but not working as well, which ideally should.

Any updates on this? My angular universal/server-side rendering no longer works. It just shows this error message. I have to downgrade to the previous version.

I have the same issue.. my universal app does no longer work ...

same here

@xiongemi please, which version worked for you?

Same problem here

I solved issue with my ssr setup by making firebase depenencies "external" in firebase config for server bunding. Just add: externals: [/^firebase/] to your webpack config, and make sure that all dependencies are installed in functions folder (package).

Any updates? I'm getting the same issue.

Adding: externals: [/^firebase/] in webpack config works.

I have added externals: [/^firebase/] in the webpack configurations file.
I received the following error:

Uncaught ReferenceError: firebase is not defined
at Object.firebase/app (main.js:11016)
at __webpack_require__ (runtime.js:80)
at Module.../../node_modules/@angular/fire/es2015/firebase.app.module.js (vendor.js:105581)
at __webpack_require__ (runtime.js:80)
at Module.../../node_modules/@angular/fire/es2015/public_api.js (vendor.js:105684)
at __webpack_require__ (runtime.js:80)
at Module.../../node_modules/@angular/fire/es2015/index.js (vendor.js:105642)
at __webpack_require__ (runtime.js:80)
at Module../src/app/app.module.ts (main.js:4981)
at __webpack_require__ (runtime.js:80)

I am using Angular framework for the renderer app.
Any idea what went wrong? maybe the regex is too inclusive in my case?

with in electron i am facing the same issue.
but above friend say "Adding: externals: [/^firebase/] in webpack config works."

here the problem is webpack config is not found in my project

help

Get the same error-message when using firebase with electron. The error message appears when the browser-window have "node-integration" enabled. The sdk seems to work for now. Only using auth and firestore.

Same here.. additionally i dont have have the the file webpack.config on my project

any update? i'm using electron+vuejs

Same here

This should be addressed in recent Firebase / AF updates

The warning seems to persist, but it seems that the gRPC recompilation issue was fixed since my final app bundle size decreased by about ~100MB 馃憦馃徏.

Still getting it on firebase 8.1.1 and @angular/fire 6.1.2

Was this page helpful?
0 / 5 - 0 ratings