简体   繁体   中英

Error importing firebase-admin

I was trying to create custom tokens using the Firebase Admin SDK. But while importing import * as admin from 'firebase-admin'; as shown here .

I got an error process.binding is not supported .

I'm using

  • browserify : 14.0.0
  • firebase : ^3.6.8
  • firebase-admin : ^4.1.0

Any ideas on how to resolve this?

Since you're using browserify and import syntax instead of the node.js module require syntax , it sounds like you're trying to use the Firebase Admin SDK in the browser. The admin SDK is only for use on a server, and is not for end-user access (see the warning at the top of the Add the Firebase Admin SDK to your Server page).

If you are trying to use the JavaScript SDK for end-user access, follow this guide instead.

If you are using this on a node.js server, try using the require syntax instead:

var admin = require("firebase-admin");

I am using Webpack for a Node application which uses firebase-admin . The solution seemed to be to set target in the Webpack configuration file to 'node' .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM