如何更新 systemjs 以查看路径?

How to update systemjs to look in paths?

根据这个问题:https://github.com/marcj/angular2-localstorage/issues/50 要将 localstorage 与 angular-cli 一起使用,我需要更新 systemjs 以查看路径:

我试过这样,但是没用

System.config({
  paths: {
   "LocalStorageEmitter": './node_modules/angular2-localstorage/dist/LocalStorageEmitter.js',
   "WebStorage": './node_modules/angular2-localstorage/dist/WebStorage.js'
 }
});

如何正确操作?

我认为您可以按照以下方式进行操作:

System.config({

map: {
"LocalStorageEmitter" : "node_modules/angular2-localstorage/dist",
"WebStorage": "node_modules/angular2-localstorage/dist"
},

packages: {
"LocalStorageEmitter": {main : "LocalStorageEmitter.js", defaultExtension: "js" },
"WebStorage": {main: "WebStorage.js", defaultExtension: "js"
}

});

现在你可以

import {__PACKAGE_NAME__} from 'LocalStorageEmitter';
import {__PACKAGE_NAME__} from 'WebStorage';

在你的一个打字稿文件中。