2016-05-18 266 views
1

我已經安裝了Angular2材料設計和庫坐在目錄Angular2材料設計

node_modules/angular2-material 

當我嘗試從angular2材料我得到(瀏覽器)導入任何組件以下錯誤

zone.js:101 GET http://localhost:4200/vendor/@angular2-material/toolbar/toolbar.js 404 (Not Found)scheduleTask @ zone.js:101ZoneDelegate.scheduleTask @ zone.js:336Zone.scheduleMacroTask @ zone.js:273(anonymous function) @ zone.js:122send @ VM3502:3fetchTextFromURL @ system.src.js:1154(anonymous function) @ system.src.js:1735ZoneAwarePromise @ zone.js:584(anonymous function) @ system.src.js:1734(anonymous function) @ system.src.js:2759(anonymous function) @ system.src.js:3333(anonymous function) @ system.src.js:3600(anonymous function) @ system.src.js:3985(anonymous function) @ system.src.js:4448(anonymous function) @ system.src.js:4700(anonymous function) @ system.src.js:406ZoneDelegate.invoke @ zone.js:323Zone.run @ zone.js:216(anonymous function) @ zone.js:571ZoneDelegate.invokeTask @ zone.js:356Zone.runTask @ zone.js:256drainMicroTaskQueue @ zone.js:474ZoneTask.invoke @ zone.js:426 
zone.js:461 Unhandled Promise rejection: Error: XHR error (404 Not Found) loading http://localhost:4200/vendor/@angular2-material/toolbar/toolbar.js 
     at XMLHttpRequest.wrapFn [as _onreadystatechange] (http://localhost:4200/vendor/zone.js/dist/zone.js:769:30) 
     at ZoneDelegate.invokeTask (http://localhost:4200/vendor/zone.js/dist/zone.js:356:38) 
     at Zone.runTask (http://localhost:4200/vendor/zone.js/dist/zone.js:256:48) 
     at XMLHttpRequest.ZoneTask.invoke (http://localhost:4200/vendor/zone.js/dist/zone.js:423:34) 
    Error loading http://localhost:4200/vendor/@angular2-material/toolbar/toolbar.js as "@angular2-material/toolbar" from http://localhost:4200/app/pfa-platform.component.js ; Zone: <root> ; Task: Promise.then ; Value: Error: Error: XHR error (404 Not Found) loading http://localhost:4200/vendor/@angular2-material/toolbar/toolbar.js(…)consoleError @ zone.js:461_loop_1 @ zone.js:490drainMicroTaskQueue @ zone.js:494ZoneTask.invoke @ zone.js:426 
zone.js:463 Error: Uncaught (in promise): Error: Error: XHR error (404 Not Found) loading http://localhost:4200/vendor/@angular2-material/toolbar/toolbar.js(…)consoleError @ zone.js:463_loop_1 @ zone.js:490drainMicroTaskQueue @ zone.js:494ZoneTask.invoke @ zone.js:426 

我有以下系統config.ts

/*********************************************************************************************** 
* User Configuration. 
**********************************************************************************************/ 
/** Map relative paths to URLs. */ 
const map: any = { 
    '@angular2-material': 'vendor/@angular2-material', 
}; 

/** User packages configuration. */ 
const packages: any = { 
    '@angular2-material/core': { 
    format: 'cjs', 
    defaultExtension: 'js', 
    main: 'core.js' 
    }, 
    '@angular2-material/sidenav': { 
    format: 'cjs', 
    defaultExtension: 'js', 
    main: 'sidenav.js' 
    }, 
    '@angular2-material/toolbar': { 
    format: 'cjs', 
    defaultExtension: 'js', 
    main: 'toolbar.js' 
    } 
}; 

//////////////////////////////////////////////////////////////////////////////////////////////// 
/*********************************************************************************************** 
* Everything underneath this line is managed by the CLI. 
**********************************************************************************************/ 
const barrels: string[] = [ 
    // Angular specific barrels. 
    '@angular/core', 
    '@angular/common', 
    '@angular/compiler', 
    '@angular/http', 
    '@angular/router', 
    '@angular/platform-browser', 
    '@angular/platform-browser-dynamic', 

    // Thirdparty barrels. 
    'rxjs', 

    // App specific barrels. 
    'app', 
    'app/shared', 
    /** @cli-barrel */ 
]; 

const cliSystemConfigPackages: any = {}; 
barrels.forEach((barrelName: string) => { 
    cliSystemConfigPackages[barrelName] = { main: 'index' }; 
}); 

/** Type declaration for ambient System. */ 
declare var System: any; 

// Apply the CLI SystemJS configuration. 
System.config({ 
    map: { 
    '@angular': 'vendor/@angular', 
    'rxjs': 'vendor/rxjs', 
    'main': 'main.js' 
    }, 
    packages: cliSystemConfigPackages 
}); 

// Apply the user's configuration. 
System.config({ map, packages }); 

的package.json是

{ 
    "name": "pfa-platform", 
    "version": "0.0.0", 
    "license": "MIT", 
    "angular-cli": {}, 
    "scripts": { 
    "start": "ng server", 
    "postinstall": "typings install", 
    "lint": "tslint \"src/**/*.ts\"", 
    "test": "ng test", 
    "pree2e": "webdriver-manager update", 
    "e2e": "protractor" 
    }, 
    "private": true, 
    "dependencies": { 
    "@angular/common": "2.0.0-rc.1", 
    "@angular/compiler": "2.0.0-rc.1", 
    "@angular/core": "2.0.0-rc.1", 
    "@angular/http": "2.0.0-rc.1", 
    "@angular/platform-browser": "2.0.0-rc.1", 
    "@angular/platform-browser-dynamic": "2.0.0-rc.1", 
    "@angular/router": "2.0.0-rc.1", 
    "@angular2-material/core": "^2.0.0-alpha.4", 
    "@angular2-material/sidenav": "^2.0.0-alpha.4", 
    "@angular2-material/toolbar": "^2.0.0-alpha.4", 
    "es6-shim": "^0.35.0", 
    "reflect-metadata": "0.1.3", 
    "rxjs": "5.0.0-beta.6", 
    "systemjs": "0.19.26", 
    "zone.js": "^0.6.12" 
    }, 
    "devDependencies": { 
    "angular-cli": "^1.0.0-beta.4", 
    "codelyzer": "0.0.14", 
    "ember-cli-inject-live-reload": "^1.4.0", 
    "jasmine-core": "^2.4.1", 
    "jasmine-spec-reporter": "^2.4.0", 
    "karma": "^0.13.15", 
    "karma-chrome-launcher": "^0.2.3", 
    "karma-jasmine": "^0.3.8", 
    "protractor": "^3.3.0", 
    "ts-node": "^0.5.5", 
    "tslint": "^3.6.0", 
    "typescript": "^1.8.10", 
    "typings": "^0.8.1" 
    } 
} 

如果有人能指出我的錯誤,我將不勝感激。 在此先感謝

回答

2

的問題是非常簡單的。我沒有更新angular-cli-build.js,因此,有在dist目錄中沒有@angular2-material