angularfire icon indicating copy to clipboard operation
angularfire copied to clipboard

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

Open Supamiu opened this issue 7 years ago • 18 comments

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.

Supamiu avatar Apr 19 '19 09:04 Supamiu

any updates on this?

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

ritikrishu avatar May 14 '19 09:05 ritikrishu

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.

xiongemi avatar May 23 '19 13:05 xiongemi

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

koraysels avatar Jun 03 '19 07:06 koraysels

same here

rip222 avatar Jun 09 '19 21:06 rip222

@xiongemi please, which version worked for you?

matheo avatar Jul 13 '19 00:07 matheo

Same problem here

cyberbobjr avatar Jul 22 '19 06:07 cyberbobjr

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).

vdjurdjevic avatar Aug 03 '19 13:08 vdjurdjevic

Any updates? I'm getting the same issue.

ArcaneDisgea avatar Oct 23 '19 19:10 ArcaneDisgea

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

mises543 avatar Dec 14 '19 06:12 mises543

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?

bennymeg avatar Jan 07 '20 11:01 bennymeg

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

basantbhandari avatar Jan 20 '20 14:01 basantbhandari

help

basantbhandari avatar Jan 20 '20 14:01 basantbhandari

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.

davidtoska avatar Feb 24 '20 11:02 davidtoska

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

any update? i'm using electron+vuejs

RaynisDev avatar May 24 '20 21:05 RaynisDev

Same here

lordjoo avatar Aug 25 '20 03:08 lordjoo

This should be addressed in recent Firebase / AF updates

jamesdaniels avatar Nov 18 '20 18:11 jamesdaniels

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 👏🏼.

bennymeg avatar Nov 26 '20 14:11 bennymeg

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

Supamiu avatar Dec 06 '20 09:12 Supamiu