Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

like image 752
Curtis Avatar asked Dec 14 '17 14:12

Curtis


4 Answers

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 )

like image 116
xudre Avatar answered Nov 02 '22 01:11

xudre


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

npm i @angular/material-moment-adapter
like image 25
M.Shafiq Tahir Avatar answered Nov 02 '22 01:11

M.Shafiq Tahir


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)

like image 16
Edric Avatar answered Nov 02 '22 02:11

Edric


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.

like image 10
tallgeese117 Avatar answered Nov 02 '22 02:11

tallgeese117