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)
var firebase = require('firebase');
var config = {
apiKey: "xxxxx",
authDomain: "xxxxx.firebaseapp.com",
databaseURL: "https://xxxxx.firebaseio.com"
};
firebase.initializeApp(config);
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..
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.