Whenever I attempt to integrate the firebase-admin SDK into my Angular2 project, an error occurs:
ERROR in ./~/firebase-admin/lib/auth/token-generator.js
Module not found: Error: Can't resolve 'jsonwebtoken' in '/home/koucky/git_projects/zlepsito-web/node_modules/firebase-admin/lib/auth'
@ ./~/firebase-admin/lib/auth/token-generator.js 7:10-33
@ ./~/firebase-admin/lib/auth/auth.js
@ ./~/firebase-admin/lib/auth/register-auth.js
@ ./~/firebase-admin/lib/index.js
@ ./src/app/app.module.ts
@ ./src/main.ts
@ multi webpack-dev-server/client?http://localhost:4200 ./src/main.ts
I have installed firebase-admin using npm and attempted two ways of importing it in my app.module.ts: import 'firebase-admin'
or
var admin = require("firebase-admin");
. Unfortunately, both methods lead to the same error.
I have followed the guidelines provided at: https://firebase.google.com/docs/admin/setup
Here is a snippet from my app.module.ts:
var admin = require("firebase-admin");
var serviceAccount = require('./serviceAccountKey.json');
admin.initializeApp({
credential: admin.credential.cert(serviceAccount),
databaseURL: "https://myapp-99f41.firebaseio.com"
});
If anyone knows how to resolve this issue or has a sample code snippet on integrating the firebase-admin SDK with an Angular2 project, please share. Thanks in advance!