TypeError:Firebase不是一个功能 [英] TypeError: Firebase is not a function
问题描述
我试图按照firebase Node教程:
https://www.firebase.com /docs/web/quickstart.html
我的node.js应用程序崩溃,出现TypeError:Firebase不是函数错误。我的index.js文件:
var Firebase = require(firebase);
var firebaseRef = new Firebase(https://word-word-number.firebaseio.com/);
第二行发生崩溃。
在我的package.json中,我有:
$ p $ firebase:^ 3.0.2,
和
节点:5.11.0
firebase.com教程已经过时,应该如何使用最新的Firebase包。以下是来自 https://www.npmjs.com/package/firebase 的新指令。
在您的代码中,您可以使用以下方式访问Firebase:
var firebase = require('firebase');
firebase.intializeApp({
apiKey:'< your-api-key>',
authDomain:'< your-auth-domain>',
databaseURL:' < your-database-url>',
storageBucket:'< your-storage-bucket>'
});
或者,如果您设置服务帐户
通过新的Google Firebase信息中心的权限,使用新官方文档中引用的方法:
https://firebase.google.com/docs/server/setup#add_the_sdk
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"
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
这篇关于TypeError:Firebase不是一个功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!