Nuxt.js: [Firebase Storage] Firebase.storage is not a function.

Created on 28 Dec 2017  路  9Comments  路  Source: nuxt/nuxt.js

I'm working on a project using Nuxt and Firebase.
Everything is ok except firebase storage.

I have 2 pages:

  1. index.vue - /
  2. add.vue -/add (which implemented firebase storage)
    If I get to page no.1 first, then move to page no.2 via router. Everything is ok. Firebase storage works fine.
    BUT WHEN I GET DIRECTLY TO /ADD, I GET AN ERROR: Firebase.storage is not a function.
    I don't know why? Please help me ...!

This question is available on Nuxt.js community (#c2147)

Most helpful comment

try this, work for me.
(using nuxt.js + vuexfire)

  • plugins/firebase.js
import firebase from 'firebase'
import 'firebase/storage' // <- add

if (!firebase.apps.length) {
  firebase.initializeApp(
    {
      apiKey: 'xxx',
      authDomain: 'xxx',
      databaseURL: 'xxx',
      projectId: 'xxx',
      storageBucket: 'xxx',
      messagingSenderId: 'xxx'
    }
  )
}
const db = firebase.database()
const storage = firebase.storage()

export { storage, db }
  • SampleComponent.vue
<script>
import { storage } from '~/plugins/firebase.js'
</script>

https://github.com/angular/angularfire2/issues/1015

All 9 comments

Have you been able to figure out the problem? Is it 'hash' or 'history' in your VueRouter mode (router.js)? What command (dev, build, etc.) do you run that leads to the error?

@shinrel22 Silly question, but have you tried wrapping Firebase.storage call in a timeout to see if there's a difference? Along those lines, you might add Vuex mutation or action with the functionality which should guarantee that state is universal.

is it the same problem as here ?
I am in the same situation and the answer he gave seems brutal for me would there be another solution ?
please help

+1 firebase storage isn't working from node for me

try this, work for me.
(using nuxt.js + vuexfire)

  • plugins/firebase.js
import firebase from 'firebase'
import 'firebase/storage' // <- add

if (!firebase.apps.length) {
  firebase.initializeApp(
    {
      apiKey: 'xxx',
      authDomain: 'xxx',
      databaseURL: 'xxx',
      projectId: 'xxx',
      storageBucket: 'xxx',
      messagingSenderId: 'xxx'
    }
  )
}
const db = firebase.database()
const storage = firebase.storage()

export { storage, db }
  • SampleComponent.vue
<script>
import { storage } from '~/plugins/firebase.js'
</script>

https://github.com/angular/angularfire2/issues/1015

This seems to be resolved now. Closing. Reopen if still happens.

Hi,
I was using firebase on android for a while and when I get to create website based on firebase realtime database and firebase storage I got error:
"newRecord.js:53 Uncaught TypeError: firebase.storage is not a function;"

I am using pure js, html and css and nothing else. Also unable to find any help on internet.

Its been a day since I faced this error and I was unable to resolve it however everything else is working like a charm. I am using firebase 4.12.1. Any help appreciated!

Are you using Nuxt.js? And are you sure the problem comes from Nuxt?
The problem here is related to the fact that Firebase Storage does not work in Nuxt.js projects and this seems to be resolved now.

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

surmon-china picture surmon-china  路  3Comments

gary149 picture gary149  路  3Comments

vadimsg picture vadimsg  路  3Comments

shyamchandranmec picture shyamchandranmec  路  3Comments

pehbehbeh picture pehbehbeh  路  3Comments