【问题标题】:Attempt to use Aurelia plugin causing 404 error in browser尝试使用 Aurelia 插件导致浏览器出现 404 错误
【发布时间】:2016-12-15 15:59:44
【问题描述】:

更新:

我的困惑是我将客户端库误认为插件一词

这里记录了安装和使用库:

http://aurelia.io/hub.html#/doc/article/aurelia/framework/latest/the-aurelia-cli/6

原帖:

我正在尝试将 firebase 与新的 aurelia 应用一起使用。

我找到了这个文档:

http://aurelia.io/hub.html#/doc/article/aurelia/framework/latest/app-configuration-and-startup/7

npm install -g aurelia-cli
au new APPNAME
cd APPNAME
jspm install firebase

// main.js
//... included default code omitted

var firebaseConfig = {
  apiKey: "...",
  authDomain: "...",
  //... etc
};

// SECURITY CREDENTIALS IN YOUR SOURCE CODE??????????
// Yes, I KNOW not to put secure credentials in my source code.
// This is just a silly learning app on my own development machine
// trying to learn how to use both Aurelia and Firebase.

export function configure(aurelia) {
  aurelia.use
    .standardConfiguration()
    .feature('resources')
    .plugin('firebase', firebaseConfig);

  //... included default code omitted
}

au run --watch 加载正常

在我的浏览器和控制台中加载 http://localhost:9000 会发生这种情况:

DEBUG [aurelia] Loading plugin aurelia-templating-binding.
vendor-bundle.js:13938 DEBUG [aurelia] Configured plugin aurelia-templating-binding.
vendor-bundle.js:13938 DEBUG [aurelia] Loading plugin aurelia-templating-resources.
vendor-bundle.js:13938 DEBUG [aurelia] Configured plugin aurelia-templating-resources.
vendor-bundle.js:13938 DEBUG [aurelia] Loading plugin aurelia-event-aggregator.
vendor-bundle.js:13938 DEBUG [aurelia] Configured plugin aurelia-event-aggregator.
vendor-bundle.js:13938 DEBUG [aurelia] Loading plugin aurelia-history-browser.
vendor-bundle.js:13938 DEBUG [aurelia] Configured plugin aurelia-history-browser.
vendor-bundle.js:13938 DEBUG [aurelia] Loading plugin aurelia-templating-router.
vendor-bundle.js:13938 DEBUG [aurelia] Configured plugin aurelia-templating-router.
vendor-bundle.js:13938 DEBUG [aurelia] Loading plugin resources/index.
vendor-bundle.js:13938 DEBUG [aurelia] Configured plugin resources/index.
vendor-bundle.js:13938 DEBUG [aurelia] Loading plugin firebase.
http://localhost:9000/src/firebase.js Failed to load resource: the server responded with a status of 404 (Not Found)
vendor-bundle.js:1399 Unhandled rejection Error: Script error for "firebase"
http://requirejs.org/docs/errors.html#scripterror
    at makeError (http://localhost:9000/scripts/vendor-bundle.js:3924:17)
    at HTMLScriptElement.onScriptError (http://localhost:9000/scripts/vendor-bundle.js:5491:36)
From previous event:
    at DefaultLoader.loadModule (http://localhost:9000/scripts/vendor-bundle.js:13673:14)
    at _loadPlugin (http://localhost:9000/scripts/vendor-bundle.js:12719:21)
    at http://localhost:9000/scripts/vendor-bundle.js:12712:16
From previous event:
    at loadPlugin (http://localhost:9000/scripts/vendor-bundle.js:12711:75)
    at next (http://localhost:9000/scripts/vendor-bundle.js:12972:20)
From previous event:
    at next (http://localhost:9000/scripts/vendor-bundle.js:12972:56)
    at http://localhost:9000/scripts/vendor-bundle.js:12979:16
From previous event:
    at FrameworkConfiguration.apply (http://localhost:9000/scripts/vendor-bundle.js:12964:44)
    at Aurelia.start (http://localhost:9000/scripts/vendor-bundle.js:12581:23)
    at Object.configure (http://localhost:9000/scripts/app-bundle.js:93:13)
    at http://localhost:9000/scripts/vendor-bundle.js:11485:22
From previous event:
    at config (http://localhost:9000/scripts/vendor-bundle.js:11480:48)
    at handleApp (http://localhost:9000/scripts/vendor-bundle.js:11471:12)
    at http://localhost:9000/scripts/vendor-bundle.js:11504:13
From previous event:
    at http://localhost:9000/scripts/vendor-bundle.js:11502:40
From previous event:
    at http://localhost:9000/scripts/vendor-bundle.js:11501:29
From previous event:
    at run (http://localhost:9000/scripts/vendor-bundle.js:11497:26)
    at Object.<anonymous> (http://localhost:9000/scripts/vendor-bundle.js:11524:3)
    at Object.execCb (http://localhost:9000/scripts/vendor-bundle.js:5449:33)
    at Module.check (http://localhost:9000/scripts/vendor-bundle.js:4637:51)
    at Module.enable (http://localhost:9000/scripts/vendor-bundle.js:4929:22)
    at Object.enable (http://localhost:9000/scripts/vendor-bundle.js:5310:39)
    at Module.<anonymous> (http://localhost:9000/scripts/vendor-bundle.js:4914:33)
    at http://localhost:9000/scripts/vendor-bundle.js:3890:23
    at each (http://localhost:9000/scripts/vendor-bundle.js:3815:31)
    at Module.enable (http://localhost:9000/scripts/vendor-bundle.js:4866:17)
    at Module.init (http://localhost:9000/scripts/vendor-bundle.js:4542:26)
    at http://localhost:9000/scripts/vendor-bundle.js:5213:36

【问题讨论】:

    标签: javascript firebase jspm aurelia


    【解决方案1】:

    因为您使用了 Aurelia-CLI,并且还没有 install 命令(好),所以您必须手动将通过 JSPM 或 NPM 安装的内容添加到 aurelia_project/aurelia.json。在您的情况下,将以下内容添加到 dependencies 对象:

    {
        "name": "firebase",
        "path": "../jspm_modules/github/firebase/",
        "main": "firebase"
    }
    

    这没用

    我的建议

    根据我使用 Aurelia 和 CLI 的经验,这些完全是个人的。

    你想使用 JSPM

    Download 并使用骨架,而不是 CLI。

    您想使用 CLI

    最好从 NPM 下载您的第 3 方库,并将它们包含在您的 aurelia.json 中,然后跟随 the documentation。 如果从 GitHub 下载,请将所有库放在同一个文件夹中并更新 aurelia.json 文件,就像使用 NPM 包一样。

    【讨论】:

    • 谢谢。到目前为止,这似乎是正确的方法,但是到目前为止我很难让它工作。我现在在哪里是路径和主要需要更新:“path”:“../jspm_packages/github/firebase”,“main”:“firebase-bower@3.6.4”但是现在当我运行 au run它似乎正在尝试使用 package.json 中的路径?代码:'ENOENT',系统调用:'open',路径:'github:firebase/firebase-bower@3.6.4/firebase.js',文件名似乎正确...文件名:'/Users/joemsak/ work/todo/jspm_packages/github/firebase/firebase-bower@3.6.4.js' }
    • 抱歉,我忘记了github 部分。它是否适用于这个更新的路径?如果没有,错误信息是否改变了?
    • 嘿@nicovank 非常感谢您的帮助。在上面的评论中查看我的最新编辑。
    • 我只想评论一下我使用了 aurelia-cli 因为主页演示视频建议这样做。然后我发现我的问题中链接的插件文档。根据我的经验,我是否可以进行任何文档编辑并将其作为 PR 发送到某个地方以提供帮助?
    • 我将尝试重现此问题(不是使用 firebase,而是使用任何 JSPM 包),看看它的行为方式。在使用 CLI 时,我通常只使用 NPM 包。
    猜你喜欢
    • 2020-10-05
    • 1970-01-01
    • 2013-02-06
    • 2016-03-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-09-21
    • 1970-01-01
    相关资源
    最近更新 更多