Cannot use or install firebase in nodejs

When I use this statement in my glitch webhook program :

const fb = require(‘firebase’);

so I can access database and store information, I get this error :

internal/modules/cjs/loader.js:613
throw err;
^
Error: Cannot find module ‘firebase’
Require stack:

  • /app/app.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:610:15)
    at Function.Module._load (internal/modules/cjs/loader.js:526:27)
    at Module.require (internal/modules/cjs/loader.js:666:19)
    at require (internal/modules/cjs/helpers.js:16:16)
    at Object. (/app/app.js:15:12)
    at Module._compile (internal/modules/cjs/loader.js:759:30)
    at Object.Module._extensions…js (internal/modules/cjs/loader.js:770:10)
    at Module.load (internal/modules/cjs/loader.js:628:32)
    at Function.Module._load (internal/modules/cjs/loader.js:555:12)
    at Function.Module.runMain (internal/modules/cjs/loader.js:826:10)

I also tried to install firebase from the console by writing :

npm i firebase

but didn’t solve the problem. I also tried in the console this command :slight_smile:

enable-pnpm

didn’t work aswell, I still get the above error.

1 Like

does the npm i firebase fail?

other note: npm i adds the dependency to package.json. run refresh after that to make sure glitch is aware of the change and won’t undo it later. or use glitch’s own ui for adding dependency packages. open package.json in the editor to get started with that.

1 Like

I did use refresh, but still nothing would change. Also, the firebase is added in the package.json dependency section, but still it won’t work.

1 Like

check the project logs to see if there’s a failure to install that package

1 Like

This is the log after installing the package

npm i firebase --save

protobufjs@6.11.3 postinstall /app/node_modules/@grpc/proto-loader/node_modules/protobufjs
node scripts/postinstall

protobufjs@7.1.2 postinstall /app/node_modules/protobufjs
node scripts/postinstall

npm WARN node-fetch@2.6.7 requires a peer of encoding@^0.1.0 but none is installed. You must install peer dependencies yourself.
npm WARN ws@8.11.0 requires a peer of bufferutil@^4.0.1 but none is installed. You must install peer dependencies yourself.
npm WARN ws@8.11.0 requires a peer of utf-8-validate@^5.0.2 but none is installed. You must install peer dependencies yourself.
npm WARN whatsapp-cloudapi-quick-start@1.0.0 No repository field.

  • firebase@9.14.0
    added 113 packages from 95 contributors, removed 89 packages, updated 11 packages and audited 124 packages in 75.017s
    found 0 vulnerabilities
1 Like

is there something weird about that package where it doesn’t expose a js module?

1 Like

I don’t know, those are the only errors I get

1 Like

Hi OP, I wasn wondering did you find a solution for your issue with firebase module not being found? I have a similar issue when I try to use it in my node express app:

Error: Cannot find module ‘firebase’

at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
at Function.Module._load (internal/modules/cjs/loader.js:562:25)
at Module.require (internal/modules/cjs/loader.js:692:17)
at require (internal/modules/cjs/helpers.js:25:18)
Jump Toat Object. (/app/server.js:8:18)
at Module._compile (internal/modules/cjs/loader.js:778:30)
at Object.Module._extensions…js (internal/modules/cjs/loader.js:789:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)

I have also tried the above suggestions and refresh page but nothing resolves the error.

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.