JSPM地图的依赖关系不能正确恢复路径

时间:2016-06-26 19:08:55

标签: systemjs jspm angularfire2

我对JSPM感到非常沮丧,这只是许多人中最新的问题。

我已经通过 - angularfire2通过JSPM安装了sudo jspm install npm:angularfire2(是的,SUDO。没有SUDO也没有工作!!)已经安装 @angular个依赖项。生成的包json看起来像这样 -

"jspm": {
  "dependencies": {
    "angularfire2": "npm:angularfire2@^2.0.0-beta.2"
  },
  "devDependencies": {
    "typescript": "npm:typescript@^1.8.10"
  }
}

生成的配置看起来像这样 -

System.config({
  baseURL: "/",
  defaultJSExtensions: true,
  transpiler: "typescript",
  typescriptOptions: {
    "emitDecoratorMetadata": true
  },
  paths: {
    "github:*": "jspm_packages/github/*",
    "npm:*": "jspm_packages/npm/*"
  },

  packages: {
    "app": {
      "main": "./app.ts",
      "defaultExtension": "ts"
    }
  },

  map: {
    "angularfire2": "npm:angularfire2@2.0.0-beta.2",
    "typescript": "npm:typescript@1.8.10",

    ...

    "npm:angularfire2@2.0.0-beta.2": {
      "@angular/common": "npm:@angular/common@2.0.0-rc.2",
      "@angular/compiler": "npm:@angular/compiler@2.0.0-rc.2",
      "@angular/core": "npm:@angular/core@2.0.0-rc.2",
      "@angular/platform-browser": "npm:@angular/platform-browser@2.0.0-rc.2",
      "@angular/platform-browser-dynamic": "npm:@angular/platform-browser-dynamic@2.0.0-rc.2",
      "firebase": "npm:firebase@3.0.5",
      "rxjs": "npm:rxjs@5.0.0-beta.6"
    }

    ...
  }
});

因此,当我刷新应用程序的页面时,我看到它正确导入angularfire2.js,然后尝试导入@angular/platform-browser-dynamic.js。但是它试图导入的地址是 - http://localhost:8000/@angular/platform-browser-dynamic.js这是错误的路径!我想象的是因为app.ts的第一行(以及应用程序的起点)有这一行 - import { bootstrap } from '@angular/platform-browser-dynamic';。但是,为什么JSPM没有正确映射这个?我需要单独安装这些软件包吗?如果是这样的 - 为什么会出现包依赖这样的东西?

预期:解析此导入时,应解析/jspm_packages/npm/**地址。

获得:SystemJS尝试从Web根目录/加载包。

1 个答案:

答案 0 :(得分:0)

您必须在地图中手动添加以下内容。

"@angular/common": "npm:@angular/common@2.0.0-rc.2",
"@angular/compiler": "npm:@angular/compiler@2.0.0-rc.2",
"@angular/core": "npm:@angular/core@2.0.0-rc.2",
"@angular/platform-browser": "npm:@angular/platform-browser@2.0.0-rc.2",
"@angular/platform-browser-dynamic": "npm:@angular/platform-browser-dynamic@2.0.0-rc.2",

不确定这是否是真正的解决方案但是有效。 未来就在这里。