0

我正在尝试使用 Firebase admin SDK,如ionic2中所述。但是当我打电话时admin.initializeApp,我收到了这个错误:

  import * as admin from "firebase-admin";
  ....
  admin.initializeApp({
  credential: admin.credential.cert({
    projectId: "<PROJECT_ID>",
    clientEmail: "foo@<PROJECT_ID>.iam.gserviceaccount.com",
    privateKey: "-----BEGIN PRIVATE KEY-----\n<KEY>\n-----END PRIVATE KEY-----\n"
  }),
  databaseURL: "https://<DATABASE_NAME>.firebaseio.com"
});


Error: Cannot find module "dns"
at webpackMissingModule (http://localhost:8101/build/main.js:178777:75)
at Object.<anonymous> (http://localhost:8101/build/main.js:178777:156)
at Object.<anonymous> (http://localhost:8101/build/main.js:180128:30)
at __webpack_require__ (http://localhost:8101/build/main.js:20:30)
at Object.<anonymous> (http://localhost:8101/build/main.js:178726:18)
at __webpack_require__ (http://localhost:8101/build/main.js:20:30)
at Object.<anonymous> (http://localhost:8101/build/main.js:132218:15)
at Object.internals.rfc3986 (http://localhost:8101/build/main.js:132683:30)
at __webpack_require__ (http://localhost:8101/build/main.js:20:30)
at Object.<anonymous> (http://localhost:8101/build/main.js:42488:13)

我已经安装了 dns 模块npm install dns,但仍然出现此错误。有什么想法可以解决这个问题吗?

4

0 回答 0