最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - TypeError: Firebase is not a function - Stack Overflow

programmeradmin3浏览0评论

I am trying to follow the firebase Node tutorial: .html

My node.js app is crashing with a "TypeError: Firebase is not a function" error. My index.js file:

var Firebase = require("firebase");
var firebaseRef = new Firebase("/");

Line two is where the crash happens.

In my package.json I have:

"firebase": "^3.0.2",

and

"node": "5.11.0"

I am trying to follow the firebase Node tutorial: https://www.firebase.com/docs/web/quickstart.html

My node.js app is crashing with a "TypeError: Firebase is not a function" error. My index.js file:

var Firebase = require("firebase");
var firebaseRef = new Firebase("https://word-word-number.firebaseio.com/");

Line two is where the crash happens.

In my package.json I have:

"firebase": "^3.0.2",

and

"node": "5.11.0"
Share Improve this question asked May 22, 2016 at 0:46 Andrew SchreiberAndrew Schreiber 14.9k6 gold badges49 silver badges55 bronze badges
Add a comment  | 

2 Answers 2

Reset to default 15

It turns out that the firebase.com tutorial is out-of-date with how the latest firebase package should be used. Below are the new instructions from https://www.npmjs.com/package/firebase

In your code, you can access Firebase using:

var firebase = require('firebase');
firebase.intializeApp({
  apiKey: '<your-api-key>',
  authDomain: '<your-auth-domain>',
  databaseURL: '<your-database-url>',
  storageBucket: '<your-storage-bucket>'
});

Alternatively, if you setup a Service Account via Permissions in the new Google Firebase dashboard, use the approach referenced in the new official docs here:

https://firebase.google.com/docs/server/setup#add_the_sdk

Updated documentation for nodeJs users https://firebase.google.com/support/guides/firebase-web#get_a_database_reference_numbered This will probably fix all those errors.

发布评论

评论列表(0)

  1. 暂无评论