4

Error:

Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'path')

according to my testing,

   import { getStorage, ref, uploadBytesResumable, getDownloadURL } 
    from "https://www.gstatic.com/firebasejs/9.1.1/firebase-storage.js";
    
    import { getDatabase, set, child, get, update, remove } 
    from "https://www.gstatic.com/firebasejs/9.1.1/firebase-database.js";
    
    const realdb = getDatabase();

the error is becuase ref( ) function from firebase-storage is different from ref( ) from firebase-database

but i can import only one of the function, so what to do? to save the downloadURL i need both (firebase-storage) and (firebase-database).

1 Answer 1

4

You can just rename one of the imports like this:

import { getStorage, ref as storageRef } from "https://www.gstatic.com/firebasejs/9.1.1/firebase-storage.js";

Then make sure you used storageRef() instead of ref() for storage in your code.

2
  • 1
    thanks you so much, i didn't know it was so easy the error is resolved, my hunch was correct ref functions from both liabraries were conflicting. Oct 11, 2021 at 18:17
  • 1
    @HassaanRaza If you ever use deconstruction assignments, you can also rename the exported properties like so: const { getStorage, ref: storageRef } = firebaseStorageExports; (don't actually use a firebaseStorageExports object, just used here as an example to match above) Oct 11, 2021 at 21:54

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.