Angular2 jspm依赖问题

时间:2016-01-17 17:41:13

标签: angular jspm

切换到jspm以进行Angular2包管理(而不是使用脚本标记)后,我有一些没有加载。它似乎是在根目录中查找它们:http://localhost:55707而不是在config.js中指定的jspm位置。

Failed to load resource: the server responded with a status of 404 (Not Found)
Error: XHR error (404 Not Found) loading http://localhost:55707/zone.js(…)
http://localhost:55707/reflect-metadata.js Failed to load resource: the server responded with a status of 404 (Not Found)
http://localhost:55707/es6-shim.js Failed to load resource: the server responded with a status of 404 (Not Found)
http://localhost:55707/rxjs/add/operator/map.js Failed to load resource: the server responded with a status of 404 (Not Found)

Config.js

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

  map: {
    "angular2": "npm:angular2@2.0.0-beta.1",
    "typescript": "npm:typescript@1.7.5",
    "github:jspm/nodelibs-assert@0.1.0": {
      "assert": "npm:assert@1.3.0"
    }, 
    "npm:angular2@2.0.0-beta.1": {
      "crypto": "github:jspm/nodelibs-crypto@0.1.0",
      "es6-promise": "npm:es6-promise@3.0.2",
      "es6-shim": "npm:es6-shim@0.33.13",
      "process": "github:jspm/nodelibs-process@0.1.2",
      "reflect-metadata": "npm:reflect-metadata@0.1.2",
      "rxjs": "npm:rxjs@5.0.0-beta.0",
      "zone.js": "npm:zone.js@0.5.10"
    },
    // -- more mappings
  }
});

1 个答案:

答案 0 :(得分:0)

如果您要直接导入zone.js,则需要额外的map条目。

    "angular2": "npm:angular2@2.0.0-beta.1",
    "typescript": "npm:typescript@1.7.5",
    "zone.js": "npm:zone.js@0.5.10", //<-- Add this line
    "github:jspm/nodelibs-assert@0.1.0": {

看起来你也需要一些其他包的条目。如果您的包直接依赖它们,请以相同的方式添加它们。如果它们被依赖项使用,则可能需要指定package overrides以使它们可用于依赖项。