alfredoizjr [3:12 PM] 我需要帮助,当我安装sdk firebase
时npm install firebase-admin --save
他们我在我的服务上导入了这个
import * as admin from "firebase-admin";
他们我尝试删除像这样的用户
deleteWorker(uid){
let ref = this.fb.collection('users').doc(uid).delete();
admin.auth().deleteUser(uid);
}
但我收到此错误
./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
有人可以帮我吗?
答案 0 :(得分:2)
在构建MEAN堆栈应用程序时遇到了相同的错误,我在同一文件夹(单个package.json)下安装了firebase和firebase-admin。
最后,我找到了解决方法here
基本上,您需要使用webpack-node-externals来排除node_modules
文件夹
1)。npm install webpack-node-externals --save-dev
2)。在您的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
...
};
答案 1 :(得分:0)
Admin SDK无法部署在Angular等客户端Web框架上。它只能在受信任的服务器端环境中使用。有关其他详细信息,请参见https://medium.com/@hiranya911/firebase-the-server-side-story-1f89064e9c16。
请参阅问题github.com/firebase/firebase-admin-node/issues/147