0

Im getting issues using ng2-bootstrap in angular 2. SystemJS cannot resolve moment to the node_modules dir, it instead complains about a relative path.

This is referenced from a component constructed by a route, using import

import { TOOLTIP_DIRECTIVES } from 'ng2-bootstrap';

Can anyone help?

Thanks in advance.

<script src="~/node_modules/systemjs/dist/system.src.js"></script>
<script src="~/node_modules/es6-shim/es6-shim.min.js"></script>
<script src="~/node_modules/angular2/bundles/angular2-polyfills.js"></script>
<script src="~/node_modules/moment/min/moment.min.js"></script>
<script src="~/node_modules/ng2-bootstrap/ng2-bootstrap.js"></script>
<script>
    System.config({
        defaultJSExtensions: true,
        baseURL: '/ECAV.Admin/node_modules',
        packages: {
            'app': { format: 'register', defaultExtension: 'js' },
            'rxjs': { defaultExtension: 'js' }
        },
        paths: {
            'angular2/*': 'angular2/*',
            'rxjs': 'rxjs/bundles/Rx.js',
            'linqsharp': 'linqsharp/built/linqsharp',
            'highcharts': 'highcharts',
            'ng2-highcharts': 'ng2-highcharts/ng2-highcharts',
            'lodash': 'lodash/lodash',
            'ng2-bootstrap':'ng2-bootstrap/ng2-bootstrap'
        },
        map: {
            moment: 'moment/moment.js'
        }
    });
</script>
<script src="~/node_modules/rxjs/bundles/Rx.js"></script>
<script src="~/node_modules/angular2/bundles/angular2.dev.js"></script>
<script src="~/node_modules/lodash/lodash.js"></script>
KnowHoper
  • 4,352
  • 3
  • 39
  • 54

1 Answers1

0

Regarding the configuration of the moment library, you could try this instead:

System.config({
  (...)
  map: {
    'moment': 'moment/moment'
  },
  (...)
});

See this question:

Community
  • 1
  • 1
Thierry Templier
  • 198,364
  • 44
  • 396
  • 360