[Vuejs]-Cannot import firebase to vue after adding with NPM

0👍

If you installedenter code here firebase correctly, you shouldnt have any issues.
First of all you need to create a new firebase file in your root. You can either put it in a folder or just leave it in the root.

In your fire base file there you can import what aspect of firebase you wanna use. If you are not oushing to production yet you can just import all of firebase like below.

You should import do this in your firebase.js file you created in your root

import firebase from 'firebase/'

// set your config from your firebase app your created on the firebase website

 var firebaseConfig = {
  apiKey: "AIzaSyAkjYLidJiyTLEPtODFfP2JVFJiXs9EZRQ",
  authDomain: "shoerack-b451e.firebaseapp.com",
  databaseURL: "https://shoerack-b451e.firebaseio.com",
  projectId: "shoerack-b451e",
  storageBucket: "",
  messagingSenderId: "533681909298",
  appId: "1:533681909298:web:f08c99d00568f24c99562b"
};

const fb = firebase.initializeApp(firebaseConfig);

export {fb}

Then in your main.js you can import fb from the firebase file your created like so.

import { fb } from './firebase'

Leave a comment