将Firebase-Admin与Aurelia集成

时间:2018-04-04 11:28:40

标签: javascript firebase aurelia fs firebase-admin

在我的aurelia项目中尝试实施firebase-admin时,我遇到了一些问题,我想知道是否有人可以帮助我。

我首先通过控制台安装了firebase-admin:

npm install --save firebase-admin

然后在main.js上,我将其作为管理员导入并声明了serviceAccount。

import * as admin from 'firebase-admin';
serviceAccount: './serviceAccountKey.json';

在同一页面上,在导出功能配置(aurelia)中我把它:

  admin.initializeApp({
    credential: './serviceAccountKey.json',
    databaseURL: 'https://contactmanager-be4d3.firebaseio.com'
  });

我还确保在aurelia.json文件中引用firebase-admin:

  {
    "name": "firebase-admin",
    "path": "../node_modules/firebase-admin/lib",
    "main": "index"
  },

但是在跑步时,我收到了这个错误:

{ Error: ENOENT: no such file or directory, open 'C:\Users\vasco.bento\chapter-3\app\src\fs.js'
    at Object.fs.openSync (fs.js:646:18)
    at Object.fs.readFileSync (fs.js:551:33)
    at Object.exports.readFileSync (C:\Users\vasco.bento\chapter-3\app\node_modules\aurelia-cli\lib\file-system.js:49:13)
    at fileRead (C:\Users\vasco.bento\chapter-3\app\node_modules\aurelia-cli\lib\build\bundled-source.js:83:31)
    at Object.context.fileRead (C:\Users\vasco.bento\chapter-3\app\node_modules\aurelia-cli\lib\build\amodro-trace\lib\loader\Loader.js:176:18)
    at Object.context.load (C:\Users\vasco.bento\chapter-3\app\node_modules\aurelia-cli\lib\build\amodro-trace\lib\loader\Loader.js:357:30)
    at Module.load (eval at <anonymous> (C:\Users\vasco.bento\chapter-3\app\node_modules\aurelia-cli\lib\build\amodro-trace\lib\loader\Loader.js:14:1), <anonymous>:832:29)
    at Module.fetch (eval at <anonymous> (C:\Users\vasco.bento\chapter-3\app\node_modules\aurelia-cli\lib\build\amodro-trace\lib\loader\Loader.js:14:1), <anonymous>:822:66)
    at Module.check (eval at <anonymous> (C:\Users\vasco.bento\chapter-3\app\node_modules\aurelia-cli\lib\build\amodro-trace\lib\loader\Loader.js:14:1), <anonymous>:854:30)
    at Module.enable (eval at <anonymous> (C:\Users\vasco.bento\chapter-3\app\node_modules\aurelia-cli\lib\build\amodro-trace\lib\loader\Loader.js:14:1), <anonymous>:1173:22)
  errno: -4058,
  code: 'ENOENT',
  syscall: 'open',
  path: 'C:\\Users\\vasco.bento\\chapter-3\\app\\src\\fs.js',
  moduleTree: [ 'firebase-admin/firebase-namespace' ],
  fileName: 'C:/Users/vasco.bento/chapter-3/app/node_modules/firebase-admin/lib/firebase-namespace.js' }

这是有道理的,因为fs不在lib文件夹中,或者在node_modules / firebase-admin中的任何文件夹中。

firebase-admin folder

我想知道我是如何能够解决这个问题的,以及使用Aurelia设置firebase-admin的最佳方法。

0 个答案:

没有答案