Intermediate React and Firebase Tutorial - Build an Evernote Clone

Hello freeCode Camp have a video tutorial on youTube.
This title: Intermediate React and Firebase Tutorial - Build an Evernote Clone

I folow step by step but i get an error at 8:23

firebase.initializeApp is not a function

Here is the code:

import React from 'react';

import ReactDOM from 'react-dom';

import './index.css';

import App from './App';

import reportWebVitals from './reportWebVitals';

const firebase = require('firebase');

require('firebase/firestore')

firebase.initializeApp({here is the object i do not paste here})

Hello @nikolicsmilan77 all you have to do is change the required line of code

from

firebase.initializeApp(firebaseConfig);

To this

firebase.default.initializeApp(firebaseConfig); 
1 Like

Thank you

The problem also solve If I replace >> const firebase = require(‘firebase’); << with this >> import firebase from ‘firebase’; << then work

But I don’t know why???

@nikolicsmilan77 Glad your issue has been resolved. The major difference between require and import , is that require will automatically scan node_modules to find modules, but import , which comes from ES6, won’t.

For more info on ‘require’ & ‘import’, read through below links.

require - Requiring modules in Node.js: Everything you need to know

import - An Update on ES6 Modules in Node.js

1 Like