Andrew Stockton
Andrew Stockton

Reputation: 43

error TS2307: Cannot find module 'moment' in moment-date-adapter.d.ts

Using Angular 6, I am having trouble with my material-moment-adapter. In my moment-date-adapter.d.ts file it shows that "'module' cannot be found" on my import statements when trying to import { Moment } from

node_modules/@angular/material-moment-adapter/typings/adapter/moment-date-adapter.d.ts.

My tsconfig.json is as follows:

{
  "compileOnSave": false,
  "compilerOptions": {
    "baseUrl": "./",
    "outDir": "./dist/out-tsc",
    "sourceMap": true,
    "declaration": false,
    "module": "es2015",
    "moduleResolution": "node",
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "target": "es5",
    "typeRoots": [
      "node_modules/@types"
    ],
    "lib": [
      "es2017",
      "dom"
    ] 
  }
}

My import statement is simply

import { Moment } from 'moment';

from my moment-date-adapter.d.ts file.

Any help would be appreciated.

Upvotes: 4

Views: 5711

Answers (2)

RobinPel
RobinPel

Reputation: 96

Installing @types/moment as a dev dependency solved it for me.

Upvotes: 8

Amrou TN
Amrou TN

Reputation: 1

try to install Moment.js: npm i moment

Upvotes: -3

Related Questions