0

我对 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 root 加载包/

4

1 回答 1

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",

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

于 2016-06-26T19:20:51.467 回答