尝试使用 Aurelia 插件导致浏览器出现 404 错误

Attempt to use Aurelia plugin causing 404 error in browser

更新:

我的困惑是我把客户端库误认为是插件

安装和使用库记录在此处:

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

原版POST:

我正在尝试将 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 运行 --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

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

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

This did not work

我的建议

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

您想使用 JSPM

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

您想使用 CLI

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