2016-12-27 79 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' 
相關問題