Unable to add moment.js or ng2-bootstrap to angular2 project

I get this message when my gulp tslint task starts. I'm not sure how to add moment.js so that ng2-bootstrap is happy.

node_modules / ng2-bootstrap / components / datepicker / date-formatter.ts (1,25): TS2307 error: the moment module cannot be found.

Here is my project on GitHub. It should work with Visual Studio 2015 without additional configuration.

I updated the systemjs configuration as indicated:

System.config({
  packages: {
    app: {
      format: 'register',
      defaultExtension: 'js'
    }
  },
  map: {
    moment: '../lib/moment/min/moment.min.js'
  }
});
System.import('app.js')
      .then(null, console.error.bind(console));

I added this import to my components file. This is what generates the error.

import {BUTTON_DIRECTIVES} from 'ng2-bootstrap/ng2-bootstrap';

I download this module using NPM.

"moment": "^2.11.2",

I copy all library files to wwwroot in my gulp file. Maybe I need to copy more files? I dont know.

+4
1

typescript , .

--save

ts. ///

, github .

0

Source: https://habr.com/ru/post/1627699/


All Articles