我正在從Angular 2 quickstart中嘗試添加第三方組件(特定於ng2-split-pane)。我與故宮安裝了它,並根據它的plunkr例子,我有以下systemjs.config.js:無法通過npm使用外部angular2模塊
(function (global) {
System.config({
paths: {
// paths serve as alias
'npm:': 'node_modules/'
},
// map tells the System loader where to look for things
map: {
// our app is within the app folder
app: 'app',
// angular bundles
'@angular/core': 'npm:@angular/core/bundles/core.umd.js',
'@angular/common': 'npm:@angular/common/bundles/common.umd.js',
'@angular/compiler': 'npm:@angular/compiler/bundles/compiler.umd.js',
'@angular/platform-browser': 'npm:@angular/platform-browser/bundles/platform-browser.umd.js',
'@angular/platform-browser-dynamic': 'npm:@angular/platform-browser-dynamic/bundles/platform-browser-dynamic.umd.js',
'@angular/http': 'npm:@angular/http/bundles/http.umd.js',
'@angular/router': 'npm:@angular/router/bundles/router.umd.js',
'@angular/forms': 'npm:@angular/forms/bundles/forms.umd.js',
'@angular/material': 'npm:@angular/material/bundles/material.umd.js',
// other libraries
'rxjs': 'npm:rxjs',
'angular-in-memory-web-api': 'npm:angular-in-memory-web-api/bundles/in-memory-web-api.umd.js',
'autobahn': 'npm:@types/autobahn/index.d.ts',
'ng2-split-pane': 'npm:ng2-split-pane/lib/ng2-split-pane.js',
},
// packages tells the System loader how to load when no filename and/or no extension
packages: {
app: {
main: './main.js',
defaultExtension: 'js'
},
rxjs: {
defaultExtension: 'js'
}
}
});
})(this);
及以下app.module.ts:
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import { MaterialModule } from '@angular/material';
import { BattleLogComponent } from './battlelog.component';
import { SplitPaneModule } from 'ng2-split-pane';
@NgModule({
imports: [ BrowserModule, MaterialModule, SplitPaneModule ],
declarations: [ AppComponent, BattleLogComponent ],
bootstrap: [ AppComponent ]
})
export class AppModule { }
但我只是得到一個錯誤,說「app/app.module.ts(7,33):錯誤TS2307:找不到模塊'ng2-split-pane'。」
我可以加載其他東西(例如材料)很好,我在這裏錯過了什麼?
編輯:目錄結構(最node_modules省略空間):
.
├── app
│ ├── app.component.ts
│ ├── app.module.ts
│ ├── app.ng.css
│ ├── app.ng.html
│ ├── autobahn.service.ts
│ ├── battlelog.component.ts
│ ├── battlelog.ng.html
│ └── main.ts
├── favicon.ico
├── index.html
├── js
│ └── autobahn.min.js
├── LICENSE
├── node_modules
│ ├── mkdirp
│ ├── moment
│ ├── ms
│ ├── negotiator
│ ├── ng2-split-pane
│ ├── node-uuid
│ ├── nopt
├── package.json
├── styles.css
├── systemjs.config.extras.js
├── systemjs.config.js
├── tsconfig.json
└── tslint.json
ng2-split-pane是否出現在您的node_modules文件夾中? –
是的 - 我驗證了node_modules/ng2-split-pane/lib/ng2-split-pane.js存在並且具有SplitPaneModule的導出。 – estick
您的項目中的node_modules文件夾在哪裏?我們可以得到目錄樹嗎? –