2016-12-27 96 views
1

我正尝试在新的Angular 2项目上使用immutable.js中的List模块。当我这样做时,浏览器会尝试GET http://localhost:3000/immutable,并因404 Not Found错误而失败。无法将列表模块从immutable.js导入到Angular 2项目

这里是我做过什么:

我再修改app.module克隆角2快速入门 回购。 ts如下:

import { NgModule }  from '@angular/core'; 
import { BrowserModule } from '@angular/platform-browser'; 
import { AppComponent } from './app.component'; 
import { List } from 'immutable'; 

@NgModule({ 
    imports:  [ BrowserModule ], 
    declarations: [ AppComponent ], 
    bootstrap: [ AppComponent ] 
}) 
export class AppModule { 
    constructor() { 
    let list = List.of(1,2,3); 
    } 
} 

当我在npm start这个项目中,我得到了404错误。

我错过了一些明显的东西吗?

回答

1

经过更多的Google搜索后,我发现答案很简单。我只需要在systemjs.config.js中添加一个新元素到地图中:

// other libraries 
[...] 
'immutable': 'node_modules/immutable/dist/immutable.js'