firebase-admin-node: firebase-admin dependency errors
- Operating System version: macOS 10.12.6
- Firebase SDK version: 5.2.1
- Library version: 5.2.1
- Firebase Product: admin
I’m seeing some dependency issues. firebase-admin: 5.2.1
➜ customer-manager (master) ✗ yarn add firebase-admin .../customer-manager
yarn add v0.27.5
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Building fresh packages...
success Saved lockfile.
success Saved 2 new dependencies.
├─ @google-cloud/storage@1.2.1
└─ firebase-admin@5.2.1
Done in 4.74s.
➜ customer-manager (master) ✗ yarn start .../customer-manager
yarn start v0.27.5
$ node build/dev-server.js
> Starting dev server...
ERROR Failed to compile with 22 errors 10:37:27 PM
These dependencies were not found:
* fs in ./~/firebase-admin/lib/auth/credential.js, ./~/@google-cloud/storage/src/bucket.js and 10 others
* net in ./~/faye-websocket/lib/faye/websocket/client.js, ./~/forever-agent/index.js and 3 others
* tls in ./~/faye-websocket/lib/faye/websocket/client.js, ./~/forever-agent/index.js and 1 other
* child_process in ./~/google-auth-library/lib/auth/googleauth.js
* dns in ./~/isemail/lib/isemail.js
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 37 (5 by maintainers)
There’s no resolution. If your runtime complains about missing dependencies like
fs
,net
andchild_process
, then that’s a good indication that the Admin SDK should not be used in that environment.Are you trying to use
firebase-admin
in a client-side or browser environment? That is not supported. Some of the missing modules (fs, net etc.) are only available in server-side Node.js environments.I found that I received this error in Next.js when I mingled my
firebase-admin
app with myfirebase
client side app. To solve it, I ensured thatfirebase-admin
was never imported in a client-facing file, and then (and this is crucial) I separated the initialisation of the two apps so they were initialised in separate files.@crossRT did you found any solutions? I try to use
firebase-admin
with Netlify functions and get similar errors.You áre using the same library at front-end and it is nota possible.
Firebase is used at front-end Firebase-admin is used at back-end
I installed firebase-admin at back-end and it worked.
“react”: “^16.13.1” “firebase”: “^7.19.1” “firebase-admin”: “^9.1.1”
./node_modules/hash-stream-validation/index.js Module not found: Can’t resolve ‘fast-crc32c’
./node_modules/configstore/node_modules/write-file-atomic/index.js Module not found: Can’t resolve ‘worker_threads’
Facing this Issue while trying to add Firebase Admin SDK to my React Web app
I installed firebase-admin on a brand new project which running webpack4 + typescript, getting these dependencies issue as well.
Any idea how could these happened?
Thanks for your help, it didn’t work. It shows:
Module not found: Error: Can’t resolve ‘fast-crc32c’ in ‘C:\Users\xxxxxxx\Desktop\Development\nuxt\project4\node_modules\hash-stream-validation’
ERROR Failed to compile with 43 errors 12:22:22 These dependencies were not found:
I tried this settings and it worked so far.
@hiranya911 @aaaguirrep This is not an issue with running in a browser. For me this is using TypeScript/Node deploying to backend AWS Lambdas. This is the same thing Netlify is doing.
To be clear, I am running a BACKEND Serverless project using the
serverless-webpack
plugin, developed with TypeScript, transpiled to JS by web pack, and deployed to AWS Lambda through the Serverless project. All was working well until I tried to pull in some of these odd Google Cloud SDK modules, and now I cannot run my services at all.FYI: Serverless-webpack is something I am seeing more and more of in 2019.
Not at all. It’s working perfectly in production right now.
Had a similar issue, removed node_modules and reinstalled and it worked.
Having the same issue when running
netlify-lambda
and a TypeScript function:Any clue?
Thank you so much! You saved my day!
For this solution, you need to definitely check this: https://colinhacks.com/essays/nextjs-firebase-authentication (I referred to this article)
I could find:
typeof window
shouldn’t beundefined
(as window object is in client-side - but Next.js runs Server-Side first) (Or it worked whentypeof window === 'object'
)And I could have solved the issue. My file structure and codes:
(I’ve made an
.env.local
file and then saved those keys)+) you don’t have to modify this file, but my setting for
next.config.js
I wish this could be a help
I’m building a NextJS app using “next-firebase-auth”, and ran into this issue. My deploys were building fine, but then this started popping up. The way I fixed the issue:
This was able to fix my deploys, let me know if it works for y’all
@IamMasterWayne
The Firebase Admin SDK is a server only library, the errors you are seeing are due to this. If you need to do admin operations, you need to do it in a trusted environment and expose it via an API of some kind (lambda, rest etc etc).
In my project i used the npm package:
"firebase-admin"
for accessing thefirestore
object like this:import { firestore } from "firebase-admin";
But firestore can also be imported like this:
import firestore from '@react-native-firebase/firestore';
I removed the
"firebase-admin"
package and my problem was solved:)This was on a brand new repo. Should I have to install dependencies by hand? That doesn’t seem right.