Reputation: 3449
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
Upvotes: 48
Views: 108924
Reputation: 11
You should run the following command on Angular CLI
npm i @angular/material-moment-adapter
Upvotes: 1
Reputation: 840
Just run this CMD
npm i @angular/material-moment-adapter
If it shows any error install
npm i moment
Upvotes: 12
Reputation: 1324
You must intall in @angular 5+
npm i moment
2.Material Moment Adapter
npm i @angular/material-moment-adapter
Here is the link You can visit here.
Upvotes: 1
Reputation: 1140
run the command ctrl + c for terminate. Then run again ng serve to re-run the application. after that, you can see the following image.
The issue is here. The moment js
Then run the command to install moment.js by running following common in application location.
npm i moment
After that, you can see it's installed as in the following image.
In my case, the issue was correct by these steps.
Upvotes: 2
Reputation: 591
Just run this command using npm for installing @angular/material-moment-adapter:
npm i @angular/material-moment-adapter
Upvotes: 49
Reputation: 548
Easiest step I can think of would be go to your npm package, right click
and delete
, and run command in git bash in project folder - npm install
. Installation will proceed. Other option is cd
into your c
drive, and run npm list -g
which will list all the modules you got in global setting, you would try to find the one that you are missing in this question. Third option, if nothing works blow away your global node module and re-install it. Instruction on how to do so is already answered in this link below.
How do I completely uninstall Node.js, and reinstall from beginning (Mac OS X)
Dominic Tancredi
has answered it so well. he has mentioned about how to do so in Mac
, you would remove sudo
from commands that he has mentioned to make it work in Windows
.
Upvotes: 0
Reputation: 26851
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
)
Upvotes: 16
Reputation: 2771
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 )
Upvotes: 73
Reputation: 186
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.
Upvotes: 10