4
votes

alfredoizjr [3:12 PM] Hi need help, when I install the sdk firebase

npm install firebase-admin --save

them I import this on my service

import * as admin from "firebase-admin";

them I try delete a user like this

 deleteWorker(uid){
   let ref = this.fb.collection('users').doc(uid).delete();
  admin.auth().deleteUser(uid);
 }

but I get this error

./node_modules/@google-cloud/firestore/src/v1beta1/firestore_client.js
Module not found: Error: Can't resolve './firestore_client_config' in 'C:\Users\Alfredo\Desktop\projectAngular\client-manager\node_modules\@google-cloud\firestore\src\v1beta1'
@ ./node_modules/@google-cloud/firestore/src/v1beta1/firestore_client.js 28:17-53
@ ./node_modules/@google-cloud/firestore/src/v1beta1/index.js
@ ./node_modules/@google-cloud/firestore/src/index.js
@ ./node_modules/firebase-admin/lib/firebase-namespace.js
@ ./node_modules/firebase-admin/lib/default-namespace.js
@ ./node_modules/firebase-admin/lib/index.js
@ ./src/app/services/user.service.ts
@ ./src/app/app.module.ts
@ ./src/main.ts
@ multi webpack-dev-server/client?http://localhost:4200 ./src/main.ts

some one can help me please ?

2
yes is my same question ?Alfredo Izquierdo
Alfredo did you find any solution?Unseen

2 Answers

3
votes

I got the same error while building a MEAN stack application, I was installing firebase and firebase-admin under same folder(single package.json).

Finally, I found the solution here

Basically you need to use webpack-node-externals to exclude node_modules folder

1).npm install webpack-node-externals --save-dev

2).In your webpack.config.js

var nodeExternals = require('webpack-node-externals');
...
module.exports = {
    ...
    target: 'node', // in order to ignore built-in modules like path, fs, etc.
    externals: [nodeExternals()], // in order to ignore all modules in node_modules folder
    ...
};
0
votes

Admin SDK cannot be deployed on client-side web frameworks like Angular. It can only be used in trusted server-side environments. See https://medium.com/@hiranya911/firebase-the-server-side-story-1f89064e9c16 for some additional details.

see issue github.com/firebase/firebase-admin-node/issues/147