title: How to run firebase on server side?
body: <p>I want to use firebase as a database service to my server to which a android app would send requests to. I want the server to retrieve data rather than the android app because I want to do some processing before sending data back to client (app).</p>
  
  <p>My node code (index.js) :</p>
  
  <pre><code>const express = require('express')
  const app = express()
  
  var port = process.env.PORT || 10000
  
  firebase = require('./firebase') // I added this cuz I can't use &lt;script&gt; tag here
  
  // Initialize Firebase
  var config = {
      apiKey: "AIzaSynotgonnatell2Q-kwk85XrCyNnc",
      authDomain: "hnotgonnatell.firebaseapp.com",
      databaseURL: "https://hnotgonnatell.firebaseio.com",
      projectId: "notgonnatell",
      storageBucket: "",
      messagingSenderId: "699935506077"
  };
  
  firebase.initializeApp(config);
  
  var database = firebase.database()
  
  ref = database.ref("some_table")
  
  data = {
      name : "my name",
      number : "2938019283"
  }
  
  app.get('/', function(req, res){
      ref.push(data)
      res.send("hello")
  })
  
  app.listen(port)
  </code></pre>
  
  <p>I cannot use <code>&lt;script src="https://www.gstatic.com/firebasejs/4.12.1/firebase.js"&gt;&lt;/script&gt;</code> cause I'm not connecting to firebase from client. So I instead copied the code from <a href="https://www.gstatic.com/firebasejs/4.12.1/firebase.js" rel="nofollow noreferrer">https://www.gstatic.com/firebasejs/4.12.1/firebase.js</a> and imported it into my index.js using <code>require()</code> . When I run the index.js I get:</p>
  
  <pre><code>firebase.initializeApp(config);
           ^
  
  TypeError: firebase.initializeApp is not a function
      at Object.&lt;anonymous&gt; (E:\workspace_javascript\firebase_try\index.js:24:10)
      at Module._compile (module.js:571:32)
      at Object.Module._extensions..js (module.js:580:10)
      at Module.load (module.js:488:32)
      at tryModuleLoad (module.js:447:12)
      at Function.Module._load (module.js:439:3)
      at Module.runMain (module.js:605:10)
      at run (bootstrap_node.js:422:7)
      at startup (bootstrap_node.js:143:9)
      at bootstrap_node.js:537:3
  </code></pre>
  
  <p>It works well when I run it by returning a html with firebase code inside <code>&lt;script&gt;</code></p>