Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
770 views
in Technique[技术] by (71.8m points)

javascript - TypeError: firebase.storage is not a function

Following this example, I keep getting the error:

 TypeError: firebase.storage is not a function

From this line in my code:

var storageRef = firebase.storage().ref();

(And when I simply try to initialize storage from the storage guide, linked from firebase's npm site, I get the same error.)

In my Node.js project, I'm including the following libraries:

  • const firebase = require('firebase');
  • var admin = require('firebase-admin');
  • const fs = require('fs');

Up to this point, I've successfully been able to read from and write to the firebase database, creating a reference to the database with var db = admin.database(), then var ref = db.ref("/")... So I know I've configured Firebase and firebase-database correctly. But I'm stuck on storage, and have tried both admin.storage().ref() and firebase.storage().ref(), and firebase.storage().ref("/") with the same error message.

I've also tried:

var storage = firbase.storage();
var storageRef = storage.ref();

and

const app = firebase.initializeApp(config);
var storage = app.storage();

and with ref()'s void argument () and with "/"... but have the same message, yet to no avail.

I'm using:

  • "firebase": "^3.6.4"
  • "firebase-admin": "^4.0.4"
  • Node.js : v6.9.1

What must I do to successfully create a reference to storage?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...