Errors when trying to intitialize firebase app - firebase

I just started working with firebase and I can't figure out how to initialize the app without having errors. Everytime I try to initialize the app in the import section of
#NgModule
keep getting errors [appmodule]: https://i.stack.imgur.com/ceMNQ.png
firebase config settings
I tried importing from #angular/fire/compat but when i tried to run the server it didn't work and it gave a bunch of error messages terminal errors
[]: https://i.stack.imgur.com/ceMNQ.png

Related

Firebase Deploy causing multiple errors and not deploying

Hello I am following this tutorial in order to do push notifications to multiple devices at once in Expo React Native using Firebase's cloud functions. The push tokens are stored in my RealTime-Database, but when I attempt to integrate this step after running firebase login and firebase init, I updated my index.js file to contain this code. After saving this file, I attempt to do firebase deploy and I get 70 errors. I tried to deploy it from my app directory, and didnt work, and I tried to do it from my functions directory and that didn't work. I deleted my node_modules and package-lock, and I tried to rerun expo again and clearing my npm cache. Nothing worked. I already had my firebase app initialized somewhere else, could that be the reason why? But my App itself still works, so I am not getting an error saying that the Firebase app is being initialized twice. I really dont know what else do to. Is the ESLint causing all of these errors? Should I run firebase init again without adding ESLint? Please let me know. My errors are below.
When deploying your code, by default, your code is linted using a tool called ESLint.
The "errors" you see are eslint complaining about trivial things like missing semicolons at the end of a line, using ' instead of ", improperly indented code, among other things. If you ever don't understand what a rule is trying to do, you can visit https://eslint.org/docs/rules/{rule-name} (such as https://eslint.org/docs/rules/semi).
As shown in the error message, you can use eslint . --fix to automatically fix most of these. Just enter into your functions directory and execute eslint . --fix.
Most IDEs have a keyboard shortcut for automatically formatting your code to your rules. In VSCode for example, this shortcut is Alt+Shift+F.

Linking to FireBase

After following all the steps on google, after I run the emulator from scratch I get the following message:
On the google Firebase site it also tells me "Congratulations, you've successfully added Firebase to your app! ". But I am worried I did not do things properly and do not want to run in to problems later.
I do not have any problems uploading the code to the android emulator, hence I do not know if it successfully connected to Firebase. How can I properly check if I am actually indeed connected to Firebase?
If you want to check it through your code
Try getting the user by (just for the test)
await FirebaseAuth.instance.getCurrentUser()//should return null
If it throws no error everything is setup correctly
Make sure the emulator has Google play services installed

How to use Next.js Automatic Static Site Optimization and still export for Netlify?

I have been working on implementing some of the updates from Next 9.3. I have been moving from getInitialProps to getServerSideProps and noticed that my exportPathMap became unhappy with these pages becoming dynamic. Everything works fine running next, but when I go to run next build && next export, I run into some issues.
In the docs for static html export it states If your pages don't have getInitialProps you may not need next export at all; next build is already enough thanks to Automatic Static Optimization. I am able to get that to work happily with my new getServerSideProps calls when I run next build && next start. What steps do I need to take in order for that to also work with next export so I can deploy via Netlify. Here's an example of the error I am getting when I attempt to run next export
Error occurred prerendering page "/videos/[videos_title]". Read more: https://err.sh/next.js/prerender-error:
Error: Error for page /videos/[videos_title]: pages with `getServerSideProps` can not be exported. See more info here: https://err.sh/next.js/gssp-export
Applications build with SSR cannot be deployed in Netlify or any other static hosting sites (Except Vercel, which supports NextJS SSR Deployment)
When you go for SSR (using getServerSideProps), it's meaningless to
use the command next export since it will try to create static
content which is totally opposite to the SSR.
   
One way of deployment is to run it in the Virtual Server (like EC2)
by creating custom server.js file with proper routing configuration.
Another easy & quick method is to use Vercel (Zeit
formerly) for deployment of SSR implemented Applications where
they handle it wisely
Vercel has poor documentation for deployment of SSR Applications. Luckily I've got the below information from the Support Team and requested them to update the documentation to elaborate more about the SSR Deployment in Vercel.
When deploying in Vercel,
Give Build Command as next build or npm run build
Leave the Output Directory as Empty
NOTE: Application with custom server.js will not work properly in Vercel, in that case, go for Virtual Server (Like EC2)

Firebase deploy fails after adding second project

After adding a second project to my code using the command $ firebase use --add second-project, I get the error
There was an issue deploying your functions. Verify that your project has a Google App Engine instance setup at https://console.cloud.google.com/appengine and try again. If this issue persists, please contact support.
Error: HTTP Error: 404, Could not find Application "second-project".
when I run $ firebase deploy.
I have added separate targets and a web app through Firebase console for the second project.
What should I be checking to get rid of this error?
I just ran into this same exact issue as well. Leaving this here for anyone that runs into this issue in the future. What caused this error for me was a permissions error, when Firebase tried to access specific resources in Google Cloud such as Cloud Functions without the necessary IAM/service accounts in place.
This happens when you create a new Firebase project without setting the Default GCP resource location under Settings > General in the Firebase Console, which occurs when you create a new Firebase project without doing any additional setup. You can set this in the settings or this is also set when you follow the walk-through instructions for setting up services such as Firestore or Firebase Storage in the Firebase console.
Without this set, the <YOUR_FIREBASE_PROJECT_NAME>#appspot.gserviceaccount.com IAM/service account will not be created in Google Cloud (which is needed to create/access specific resources), therefore when you run firebase deploy, it will fail with the error you mentioned above.
You can also check why your firebase deploy is failing in the firebase-debug.log that is generated when running this command (that's how I found out the cause of this error). Though I think this file is deleted after the command finishes execution, so you'll have to pipe the output into a file or save it some other way.
TL;DR: Set Default GCP resource location, one way this can be done is in the Firebase Console under Settings > General.

Firebase Storage Trigger Not Working

I created a custom bucket which I use to serve content at a specific url. In Firebase I created a bucket called "images.mydomain.com" and I wanted to use this so my users can simply go to http://images.mydomain.com/imagename.jpg to access uploaded images.
I wanted to have a firebase trigger on my new bucket that does Google vision analysis on the image. Here is my function:
export const imageUploaded = functions.storage
.bucket('images.mydomain.com').object().onChange( event => {
//Cool stuff happens here
});
However, when I try to deploy the function I get this error in the console
⚠ functions[imageUploaded]: Deployment error.
Failed to configure trigger GCS Bucket: imagebucket
When I go to the function logs in Firebase I see the exact same error
Failed to configure trigger GCS Bucket: imagebucket
I also went to the Google Cloud Console to look at the functions to hopefully get some more insight on the issue. When I looked at the function, it had the correct bucket configured for the function but it had that exact same error without any explanation.
I have tried to create a new bucket using that but I get the exact same error. It seems that no matter what I do I keep getting the same error. I've tried adding permission and every It doesn't make any sense.
Does anyone know what this is about and/or how I can get this working? I had this working on the main bucket, but I really need this to work for my new bucket.
Thanks
A quick update:
I tried to deploy to my production environment (my app isn't in market yet so no one is actually using it) and it worked perfectly, the trouble is, I really need my development environment working which isn't right now.
To solve my issue I used this GitHub issue:
https://github.com/firebase/functions-samples/issues/66
Basically, there was no answer, I just had to shutdown my development project and start a new development project. Once I started a new project my functions deployed perfectly.

Resources