Firebase-js-sdk: Error: Cannot find module '@firebase/app'

Created on 26 Sep 2018  路  8Comments  路  Source: firebase/firebase-js-sdk


[REQUIRED] Describe your environment

  • Operating System version: macOS 10.14
  • Browser version: NodeJS 10.4.1
  • Firebase SDK version: 5.5.1
  • Firebase Product: auth and database

[REQUIRED] Describe the problem

Steps to reproduce:

Trying to run a nodejs app with firebase is returning an error when starting:

internal/modules/cjs/loader.js:596
    throw err;
    ^

Error: Cannot find module '@firebase/app'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:594:15)
    at Function.Module._load (internal/modules/cjs/loader.js:520:25)
    at Module.require (internal/modules/cjs/loader.js:650:17)
    at require (internal/modules/cjs/helpers.js:20:18)
    at Object.<anonymous> (/node/node_modules/@firebase/firestore/dist/index.node.cjs.js:7:32)
    at Module._compile (internal/modules/cjs/loader.js:702:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:713:10)
    at Module.load (internal/modules/cjs/loader.js:612:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:551:12)
    at Function.Module._load (internal/modules/cjs/loader.js:543:3)

Relevant Code:

var firebase = require('firebase');

var config = {
  apiKey: "xxxxx",
  authDomain: "xxxxx.firebaseapp.com",
  databaseURL: "https://xxxxx.firebaseio.com"
};

firebase.initializeApp(config);
core

Most helpful comment

now I read your comments again and realized you don't have app inside @firebase. It's not correct. It means firebase was not installed correctly. Deleting package.lock/yarn.lock file and doing a clean install should solve the problem.

All 8 comments

Hi, I'm not able to reproduce it. Can you please try to reinstall the dependencies by deleting node_modules and npm install/yarn ?

yes, I already tried that several times...
After install I see that inside the node_modules folder there is both a @firebase folder and a firebase folder. Is that expected?

app is inside the firebase folder but not inside the @firebase one...

yep. It's expected. firebase is an umbrella package that includes all @firebase/{components}. The app inside firebase reexport symbols from @firebase/app.
Since you saw @firebase/app in your node_modules, I'm not sure why it says "Cannot find module '@firebase/app'". Are you still experiencing the issue?

now I read your comments again and realized you don't have app inside @firebase. It's not correct. It means firebase was not installed correctly. Deleting package.lock/yarn.lock file and doing a clean install should solve the problem.

Yup, that fixed it. Sorry for not coming back with that sooner. Thanks for your support!

for SSR/Universal cloud functions, have an Angular auth module that uses 'firebase/auth' - had to install firebase in /functions for it to work on firebase/prod.

@jrodl3r Can you please let us know the versions of firebase and angular fire you have installed, and also the version of firebase installed in your functions folder, and what other firebase packages you have installed in your functions folder?

As soon as I installed firebase in functions I ran into a separate issue that still isn't solved. Thanks!

I am also facing this issue..

Was this page helpful?
0 / 5 - 0 ratings