2016-04-03 6 views
0

からコンポーネントを追加することはできません私はちょうどと呼ばれるnpmjsから角度成分をダウンロードng2-easy-table(私は多分、私はそれを作成し、いくつかのミスをした、このコンポーネントの作成者です)。Angular2 - NPM

package.json

{ 
    "name": "untitled", 
    "version": "1.0.0", 
    "description": "", 
    "main": "index.js", 
    "scripts": { 
    "test": "echo \"Error: no test specified\" && exit 1", 
    "start": "concurrently \"npm run tsc:w\" \"npm run lite\" \"npm run styles\" ", 
    "tsc": "tsc", 
    "tsc:w": "tsc -w", 
    "lite": "lite-server", 
    "typings": "typings" 
    }, 
    "dependencies": { 
    "angular2": "2.0.0-beta.13", 
    "es6-promise": "^3.0.2", 
    "es6-shim": "^0.35.0", 
    "ng2-easy-table": "0.0.12", 
    "node-sass": "^3.4.2", 
    "reflect-metadata": "0.1.2", 
    "rxjs": "5.0.0-beta.2", 
    "systemjs": "0.19.24", 
    "zone.js": "^0.6.6" 
    }, 
    "devDependencies": { 
    "concurrently": "^2.0.0", 
    "lite-server": "^2.1.0", 
    "typescript": "^1.8.7", 
    "typings": "^0.7.5" 
    }, 
    "author": "", 
    "license": "ISC" 
} 

それから私はng2-easy-tableディレクティブを追加するために、単純なapp.component.tsを作成しました。それは以下のように見える

app.component.ts node_modules

import {Component} from 'angular2/core'; 

import {bootstrap} from 'angular2/platform/browser'; 
import {AppComponent} from 'ng2-easy-table/app/app.component'; 

@Component({ 
    selector: 'app', 
    templateUrl: 'app/index.html', 
    directives: [AppComponent] 
}) 

export class IndexComponent { } 

bootstrap(IndexComponent, []); 

node_moules

そしてSystem.config

<script> 
    System.config({ 
     packages: { 
      app: { 
       format: 'register', 
       defaultExtension: 'js' 
      } 
     } 
    }); 
    System.import('app/app.component') 
      .then(null, console.error.bind(console)); 
</script> 

しかし、私は起動時にアプリnpm start、私は取得していますコンソールから:

GET http://localhost:3002/ng2-easy-table/app/app.component 404 (Not Found)

Error: XHR error (404 Not Found) loading http://localhost:3002/ng2-easy-table/app/app.component (…)

enter image description here

EDIT

を@Thierry TEMPLIERが提供するConfig.styleを追加した後、私は取得しています: enter image description here

+0

System.configを追加する必要がありますが、そこに問題があります。 ':{ 'node_modules/NG2-簡単なテーブル/' 'はNG2-使いやすいテーブル/':}行わ –

+0

@EricMartinezは、私は右の私は'のパスのようなものをsystem.configに追加するのですか? – ssuperczynski

答えて

1

を追加する必要がありますSystemJSの構成内のライブラリのマップ・ブロック:

<script> 
    System.config({ 
     map: { 
      'ng2-easy-table': 'node_modules/ng2-easy-table' 
     }, 
     packages: { 
      app: { 
       format: 'register', 
       defaultExtension: 'js' 
      }, 
      'ng2-easy-table': { 
       format: 'register', 
       defaultExtension: 'js' 
      } 
     } 
    }); 
    System.import('app/app.component') 
      .then(null, console.error.bind(console)); 
+0

私は自分の質問を編集しました。これで 'http:// localhost:3000/node_modules/ng2-easy-table/app/app.component 404(見つからなかった)'を取得しています。 – ssuperczynski

+0

システム構成のパッケージブロックにエントリを追加できます。私は私の答えを更新しました... –

関連する問題