0

While I'm loving Angular 2 in all other respects, I'm finding the supporting infrastructure challenging, particularly when it comes to how to properly reference node modules in my angular2-seed projects.

I've successfully installed ng2-responsive so that it is finding it in app.module.ts:

import { ResponsiveModule } from 'ng2-responsive';

by adding this:

map: {
    'ng2-responsive': 'node_modules/ng2-responsive',
},
packages: {
    'ng2-responsive': {
        main: './index.js',
        defaultExtension: 'js'
    }
}

to seed.config.ts under SYSTEM_CONFIG_DEV

but, I'm now getting:

[...]node_modules/ng2-responsive/index.d.ts(1,90): error TS2307: Cannot find module './bootstrap/bootstrap-directives'

when it attempts to run build.dev.js after I run npm start, and the same for the other directives referenced in ng2-responsive's index.d.ts...presumably because they're referenced like this:

import { XL, LG, MD, SM, XS, ShowItBootstrap, HideItBootstrap, ResponsiveSizeInfo } from './bootstrap/bootstrap-directives';

and that path is relative to index.d.ts, not where the it's currently being run from.

Any ideas how I tell build.dev.js to look for these where they actually exist?

Many thanks

theotherdy
  • 715
  • 1
  • 7
  • 22
  • Not sure if this will help you. I haven't used this particular library. What version of Angular are you using? Also, try this: main: 'index.js' (without the "./") – Ben Richards Oct 28 '16 at 23:41
  • Thanks @BoyanKostadinov. God idea but, sadly, that doesn't help - same errors. I'm using angular2-seed and npm list tells me I'm using Angular 2.1.1 – theotherdy Oct 29 '16 at 20:32
  • 1
    I'll get angular2 seed and see what it takes to get this working. I'll get back to you. – Ben Richards Oct 29 '16 at 21:10
  • Thanks @BoyanKostadinov, that's an incredibly kind offer but it looks as if it may actually be a problem with ng2-responsive, rather than my [lack of!] understanding of systemjs: https://github.com/ManuCutillas/ng2-responsive/issues/45 so maybe worth waiting to see what the module author comes up with. Thanks again. – theotherdy Oct 29 '16 at 21:30
  • Good to know! I think he just fixed it in 6.1. You can always fork the repository and fix it yourself too. – Ben Richards Oct 30 '16 at 05:20
  • @theotherdy, Any fix? I have the same issue. – Chris Fremgen Nov 08 '16 at 15:25
  • @ChrisFremgen - that bug fix sorted it for me I'm afraid. However, with every new node module I add, I have new problems with getting it recognised and none of them seem to work in the same way e.g for ng2-charts, I had to add refer to it in project.config.ts: this.NPM_DEPENDENCIES = [ ...this.NPM_DEPENDENCIES, {src: 'ng2-charts/*.js', inject: 'libs'}, whereas angular2-material is added under paths: like this: '@angular/material': 'node_modules/@angular/material/material.umd.js',....I'm sure there's a logical explanation...but I have no idea what it is! – theotherdy Nov 08 '16 at 21:20

0 Answers0