Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Firebase + Node.js: Error: The XMLHttpRequest compatibility library was not found

Firebase + Node.js

On iOS:

  1. Installed Node.js
  2. npm install firebase --save
  3. node test.js

Where test.js is a very simply script to connect to Firebase:

var firebase = require("firebase/app");
require("firebase/auth");

var config = {
   ...
};

var app = firebase.initializeApp(config); // Works fine
firebase.auth().signInWithEmailAndPassword(…); // Throws error

The error thrown is

Error: The XMLHttpRequest compatibility library was not found.

What am I overlooking? Thanks.

like image 380
Jaap Avatar asked Dec 19 '16 01:12

Jaap


1 Answers

I had the same issue by using Angularfire2 with Universal Server Side rendering. I've solved it by adding the xmlhttprequest to my server.js file.

Just like this:

npm install xmlhttprequest --save

and adding it like:

global.XMLHttpRequest = require('xmlhttprequest').XMLHttpRequest;

or

global['XMLHttpRequest'] = require('xmlhttprequest').XMLHttpRequest;

Maybe it helps someone!

like image 119
Orlandster Avatar answered Oct 01 '22 10:10

Orlandster