MFazio23
MFazio23

Reputation: 1312

Adding npm libraries to Angular2 (v2.0.0-rc.1) app

I'm currently struggling to bring npm libraries into my Angular2 app (in particular, https://github.com/manfredsteyer/angular2-oauth2).

When I attempt to import the library into my app, I get a 404. If I add the library to my systemjs.config.js map and packages sections, I just get 404s for the library's dependencies. Once I add those dependencies, I then get 404s for each dependency's dependencies (and so on).

I've added a typings map to the GitHub repo as well:

"dependencies": {
  "angular2-oauth2": "github:manfredsteyer/angular2-oauth2/oauth-service.d.ts#0a0d321"
}

What am I missing here?

Upvotes: 1

Views: 75

Answers (1)

Thierry Templier
Thierry Templier

Reputation: 202138

You need to configure the library and its dependencies within your SystemJS configuration:

var map = {
  'app': 'app', // 'dist',
  '@angular': 'node_modules/@angular',
  'angular2-in-memory-web-api': 'node_modules/angular2-in-memory-web-api',
  'rxjs': 'node_modules/rxjs',
  'angular2-oauth2': 'node_modules/angular2-oauth2',
  'base64-js': 'node_modules/base64-js/lib/b64.js',
  'sha256': 'node_modules/sha256/lib/sha256.js',
  (...)
};

Here is a sample application with Webpack: https://github.com/manfredsteyer/angular2-rc1-sample.

Upvotes: 1

Related Questions