Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot deploy/serve Firebase with error: No "exports" main defined in package.json [closed]

'firebase' npm package is used in Functions backend for .initializeApp(config) and .Auth().signInWithEmailAndPassword(email, password)

Firebase deploy/serve throws this error:

+  functions: Using node@16 from host.
i  functions: Watching "C:\Users\ewert\Documents\Study\Udemy\Authentication\Firebase Practice\functions" for Cloud Functions...        
!!  functions: Failed to load function definition from source: FirebaseError: Failed to load function definition from source: Failed to generate manifest from function source: Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: No "exports" main defined in C:\Users\ewert\Documents\Study\Udemy\Authentication\Firebase Practice\functions\node_modules\firebase\package.json

Re-installing firebase package, updating Node, npm and using 'firebase-admin' did not solve the issue.

Tutorial link, step Section 2.1

Firebase version: 11.7.0

I'm very thankful if you can help.

like image 269
Supathi Ratnayake Avatar asked Aug 26 '21 18:08

Supathi Ratnayake


1 Answers

The Firebase js sdk is for client-side use only. In order to interact with Firebase from your backend environment (ie cloud functions, node backend, etc), you must use the admin-sdk.

Keep in mind that since the admin-sdk runs in a secure, trusted environment, it has elevated privileges and will bypass security rules, so make sure you're validating your data in your functions.

You can view the full documentation for the admin-sdk here: Firebase Admin SDK

like image 149
Hydra Avatar answered Oct 16 '22 22:10

Hydra