Cannot find module '@angular/material-moment-adapter'

65,454

Solution 1

Since @angular/material-moment-adapter requires Angular v5 and up and was only introduced recently (in 5.0.0-rc0), you have to update your dependencies as follows:

npm install -s @angular/{animations,common,compiler,compiler-cli,core,forms,http,platform-browser,platform-browser-dynamic,platform-server,router}@'^5.0.1' rxjs@'^5.5.2'
npm install -E [email protected]

Adapted from https://update.angular.io

EDIT:

Note: As of NPMJS 5, you no longer have to specify the --save flag as this is the default option (see this blog post on changes to NPMJS 5 for more info (under the breaking changes section)):

npm i @angular/{animations,common,compiler,core,forms,platform-browser,platform-browser-dynamic,router}@latest rxjs@latest moment
npm i -D [email protected]

(P.S. The -D flag is an alias of --save-dev)

Solution 2

For those, like me, that also reached this question and already have the lastest @angular 5+.

Don't forget to install Moment.js: npm i moment (as I did )

Solution 3

Just run this command using npm for installing @angular/material-moment-adapter:

npm i @angular/material-moment-adapter

Solution 4

Check out this: https://stackblitz.com/angular/gxamabemnyx

Something to note you will have to manually install the module: npm install @angular/material-moment-adapter

Looking at the package.json it's missing.

Solution 5

Just run this CMD

npm i @angular/material-moment-adapter

If it shows any error install

npm i moment
Share:
65,454
Curtis
Author by

Curtis

Software Developer

Updated on October 14, 2021

Comments

  • Curtis
    Curtis over 2 years

    Why is this not working? I try importing the MomentDateAdapter as shown on the angular website but Visual Studio Code keeps complaining it cant find @angular/material-moment-adapter. What am I doing wrong?

    version info: Angular CLI: 1.5.0 Node: 6.11.0 OS: darwin x64 Angular: 4.4.6 ... animations, common, compiler, compiler-cli, core, forms ... http, language-service, platform-browser ... platform-browser-dynamic, router, tsc-wrapped

    @angular/cdk: 2.0.0-beta.12 @angular/cli: 1.5.0 @angular/material: 2.0.0-beta.12 @angular-devkit/build-optimizer: 0.0.32 @angular-devkit/core: 0.0.20 @angular-devkit/schematics: 0.0.35 @ngtools/json-schema: 1.1.0 @ngtools/webpack: 1.8.0 @schematics/angular: 0.1.1 typescript: 2.3.4 webpack: 3.8.1

  • Edric
    Edric over 6 years
    @Curtis See my answer.
  • Curtis
    Curtis over 6 years
    ran the first command got back a bunch of lines like this: "@angular/[email protected] invalid" and "UNMET PEER DEPENDENCY @angular/[email protected] invalid"
  • Curtis
    Curtis over 6 years
    I was having issues running those commands but based on what you said about angular 5 being required I used the now updated CLI to generate a new project and copied the package.json file from the fresh project over and that seemed to work.
  • Edric
    Edric about 6 years
    Down voter, could you explain why you downvoted this answer?
  • Burnee
    Burnee almost 6 years
    @Edric: I think it would be nice to extend your answer (because this one is the accepted) with the importance of adding moment.js as xudre wrote it below
  • Edric
    Edric almost 6 years
    @Burnee Thanks for the heads up! I've added what you've said in my answer.
  • Dragos Stanciu
    Dragos Stanciu almost 6 years
    Running this plus npm i @angular/material-moment-adapter worked for me.
  • Mulperi
    Mulperi over 5 years
    Yeah this is not enough.
  • Edric
    Edric over 5 years
    @Mulperi Could you clarify?
  • imdadhusen
    imdadhusen over 3 years
    Accepted answer