【问题标题】:Firebase module breaks AureliaFirebase 模块破坏了 Aurelia
【发布时间】:2016-09-17 15:32:25
【问题描述】:

在新的 Aurelia 应用中尝试使用 Firebase NPM 模块时发现了一个神秘的错误。当我将firebase 添加到aurelia.json 配置文件时,就会触发该错误。这是au run --watch 的输出:

>au run --watch Starting 'readProjectConfiguration'... Finished 'readProjectConfiguration' Starting 'processMarkup'... Starting 'processCSS'... Starting 'configureEnvironment'... Finished 'processCSS' Finished 'configureEnvironment' Starting 'buildTypeScript'... Finished 'processMarkup' Finished 'buildTypeScript' Starting 'writeBundles'... Tracing app... Tracing environment... Tracing main... Tracing jog/index... Tracing resources/index... Tracing resources/attributes/show-progress... Tracing resources/elements/identity... Tracing resources/elements/nav-bar... Tracing app... Tracing jog/index... Tracing resources/elements/identity... Tracing resources/elements/nav-bar... Tracing text... Tracing aurelia-bootstrapper... Tracing aurelia-history-browser... Tracing aurelia-loader-default... Tracing aurelia-logging-console... Tracing aurelia-templating-binding... Tracing aurelia-templating-resources... Tracing aurelia-templating-router... Tracing aurelia-testing... Tracing firebase... { uid: 10, name: 'writeBundles', branch: false, error: { [Error: ENOENT: no such file or directory, open '<proj>\src\app-node.js'] errno: -4058, code: 'ENOENT', syscall: 'open', path: '<proj>\\src\\app-node.js', moduleTree: [ 'firebase' ], fileName: '<proj>/node_modules/firebase/firebase-node.js' }, duration: [ 7, 862992973 ], time: 1474058088994 }

总共有五个错误,几乎完全相同。为简洁起见,我将其截断为一个。 &lt;proj&gt; 代表我的项目的路径。非文件src\app-node.js 取决于我在代码中导入的模块。

文件firebase-node.js 有一个require('./app-node') 语句。看起来 Aurelia 正在尝试从 src 文件夹而不是 node_modules/firebase 获取此依赖项。

【问题讨论】:

    标签: firebase aurelia


    【解决方案1】:

    我在使用包含多个模块的包时遇到了同样的错误。您需要在aurelia.json 中配置依赖项部分,如Aurelia CLI documentation [Section: Adding Client Libraries to Your Project - CommonJS Package] 中所述。

    aurelia.json - build.bundles.dependencies

    ... other deps
    
    {
        "name": "firebase",
        "path": "../node_modules/firebase",
        "main": "firebase"
    },
    
    ... other deps
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-02-21
      • 2015-02-13
      • 1970-01-01
      • 1970-01-01
      • 2017-08-19
      • 2019-06-28
      • 2018-06-06
      • 1970-01-01
      相关资源
      最近更新 更多