4

I get this message when my gulp tslint task runs. 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): error TS2307: Cannot find module 'moment'.

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

I updated my systemjs config as specified:

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'm loading this module with NPM.

"moment": "^2.11.2",

I'm copying all the library files to wwwroot within my gulp file. Maybe I need to copy over more files? I don't know.

peinearydevelopment
  • 11,042
  • 5
  • 48
  • 76
user3448990
  • 323
  • 6
  • 15
  • Possible duplicate of [How to use moment.js library in angular 2 typescript app?](http://stackoverflow.com/questions/35166168/how-to-use-moment-js-library-in-angular-2-typescript-app) – SnareChops Feb 07 '16 at 23:33

1 Answers1

0

I was able to make the typescript transpiler happy by adding a few things.

typings install moment --save

Then I made a reference to this in the ts file. ///

I've checked in my changes so you can see it at the github link in the original question.

user3448990
  • 323
  • 6
  • 15