-
Notifications
You must be signed in to change notification settings - Fork 899
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Problem with typescript if firebase and firebase-admin live in the same node_modules. #752
Comments
Hey there! I couldn't figure out what this issue is about, so I've labeled it for a human to triage. Hang tight. |
This issues does not have all the required information. Looks like you forgot to fill out some sections. Please update the issue with more information. |
Basically if you have a webpack firebase project, then install firebase-admin since you might have some tools that use it during dev. Yarn will give you these missing dependencies warnings. After you fix them firebase for the browser is broken but the firebase-admin for the tools still works. There seems to be some sharing of modules in some incompatible way. I have to out all tools into a new folder along with a new package.json so I could separated the two firebase and firebase-admin module and their dependencies. |
It might only happen with a typescript project |
This was my original folder with yarn install:
After fixing the
Separating the two packages one with firebase and the other with firebase-admin does fix the problem but it requires a whole bunch of code changes in my system. We have had a merged packages with firebase and firebase-admin for the last year or so with no problems but since we're using typesscript these warnings are not glaring us in the face :).
|
I've seen several issues with |
The peerDependency warning don't worry me so much. The problem is fixing them causes a failed build because it seems |
Ohhh, I see. @hiranya911, I think we need to bump the firebase-admin dependency on |
I am just a bit concerned that firebase and firebase-admin use shared modules in the first place. Unless the api between the modules is pretty solid this kind of thing could happen any time. Maybe there is a way to combine firebase-admin into the firebase module and just have firebase-admin be a stub? :) I know that might be hard. |
Having the same issue here - |
The only workaround I found was to put the tools with a package.json containing firebase-admin into a subfolder and then removing firebase-admin from the main project |
Also running into this problem. I server-render some React code that uses My work around for the problem (which was hinted at here) was to downgrade to |
I'm experiencing this problem now when trying to access the auth() object. I keep getting an error that says "TypeError: firebase.auth is not a function" |
same issue |
@sk-eran I got the auth object to appear and the thing I did differently was install the modules in a different order. The first time I imported the modules (this is when the auth object wasn't appearing):
I deleted the npm folder and started from scratch although this time I reversed the order:
I didn't do anything else like delete files or folders I simply reversed the installation order by installing I hope this works for other people. |
How can you be sure that a npm install or npm ci will preserve that order? If it does you're golden. |
@richtera I honestly can't say what order its going to preserve it in but I do know I constantly tried to delete and reinstall the first way and it never worked. Once I did it the 2nd way it worked (auth appeared) the very first try. Maybe I was lucky I'm not sure? Here is the exact way I installed them along with my other installs and it worked:
and here is how it looks inside the
|
What I mean. Is after you do this. You should be able to do rm -rf node_modules
npm install If that doesn't work then it's not going to be reliable when loading things in production. I presume you're using |
I had this issue. I used LanceSamaria's workaround to get the firebase.auth function to show up. |
@jshcrowthe any update on this? With I've resorted to doing the following, which works - but seems to be unsupported according to the package READMEs:
|
@isTravis thanks, that is a life-saver. I can confirm that your workaround works consistently |
Hey all, So I've had several conversations with @hiranya911 about this over the past couple months. Ultimately the problem here is what @richtera pointed out above:
I can do some work to help alleviate this issue by better isolating There are some things that you can do, in the meantime, to help work around this issue:
It was pointed out by @isTravis that the |
@jshcrowthe are you able to give a clearer example of a workaround in practice in node? Answering my own question: const admin = require('firebase-admin');
const client = require('firebase/app');
require('firebase/auth');
// authenticate as a specific user on the server
client.auth().signInWithCredential(client.auth.GoogleAuthProvider.credential(/* auth */));
// for DB access use admin implementation (can't simulate specific user permissions)
admin.database().ref('/').once('value').then(snap => console.log(snap.val())); |
So my packages are at latest and they still depend on different versions of @isTravis's workaround does work for me. |
Is this going to be resolved soon? I'm still having the issue and the workarounds aren't helping. I'm using |
For others, I followed the guidance given on SO to install The workaround for me was to remove the firebase pkg cache from Hopefully, it works in production or I don't have to do this at all, because it'll be actually fixed by then. |
Tested with the latest firebase and firebase-admin, and I can't reproduce the issue. I'm closing this issue due to inactivity. If you experienced something similar, please open a new issue. |
This worked. |
My Solution: Completely Remove Node, NPM, NVM & Re-InstallI see a lot of people are still winding up here because of SEO. I posted a solution that worked for me on stack overflow here: https://stackoverflow.com/questions/48592656/firebase-auth-is-not-a-function/54427116#54427116 My fix involves completely removing npm, nvm, and node from my Mac, and doing a clean install with nvm. That link includes all of the steps I took. |
I hate to admit that these steps worked for me: npm uninstall --save firebase firebase-admin
rm -rf node_modules
rm package-lock.json
rm -rf ~/.npm
npm install
npm install firebase --save
npm install firebase-admin --save I can't say that they're all necessary, but I did them and it fixed this issue which I've been having for some time. Shrug emoji. |
I got this problem as well. I think the key is deleting both node_modules and package-lock.json, and then doing a fresh 'npm install'. This will install firebase and firebase-admin in the right order. |
[REQUIRED] Describe your environment
I have a node env that has some client side and server side code during development.
So both firebase and firebase-admin are in the same place.
There seems a bunch of warnings like:
But when I install
@firebase/app-types
then the client side version of firebase no longer seems to work and firebase.database is no longer a function.Add both firebase and firebase-admin and
@firebase/app-types
.[REQUIRED] Describe the problem
Steps to reproduce:
Relevant Code:
https://stackblitz.com/fork/firebase-issue-sandbox
// TODO(you): code here to reproduce the problem
The text was updated successfully, but these errors were encountered: