Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 719
Andrew Stockton Avatar asked Oct 29 '25 09:10

Andrew Stockton


1 Answers

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

like image 191
RobinPel Avatar answered Oct 31 '25 00:10

RobinPel