Angular Compilation Warnings with Angular Material Declarations

ぃ、小莉子 提交于 2019-12-02 21:53:26

You will need to combine answers from Reid as well from Jens Mander

Do it in this order:

npm update @angular/cli @angular/cdk rxjs
npm install -S @angular/material @angular/cdk @angular/animations
npm uninstall @angular/core
npm install -S @angular/core

After Angular meterials started work for me

I also have the same problem, then I changed the version of angular material.

Option 1 :: you can use the following commands to change your angular material version.

npm install --save @angular/material@7.3.7
npm install --save @angular/cdk@7.3.7

you can check all the list of versions at angular material

Option 2: Try updating your angular version from 7 to 8

If you have Angular 7, you should have Angular Material Version 7 too. So please install

npm install @angular/material@7.3.7 
npm install @angular/cdk@7.3.7

If you have a package.json-file delete the node_modules folder, an in your console type npm install. This should reinstall all your node_modules. After that the warnings were gone.

This is a versioning issue. If you're aiming to use Material 8.0.0, then you will need synchronized versions of complementary packages. Try the following.

npm update @angular/cli @angular/cdk rxjs

After the above command completes running, run the following from the Angular Material docs

npm install --save @angular/material @angular/cdk @angular/animations

This should keep all the versions of Angular, Material and RxJS in sync and ready for you to start using Angular Material and RxJS in an Angular 8 project.

As a general update check idea, when you're updating Angular or anything along with corresponding packages, these sorts of issues pop up all the time. Try pulling the trigger on major version updates when each piece of the puzzle is tested and stable, like it is now, and you can avoid being stuck in a dependency hell where a piece of your application will be mismatched and hold you back from continuing to build what you want.

just make some changes in package.json:

@angular/cdk": "^7.0.3"
@angular/material": "^7.0.3"

These should be match with your angular version.

A general way to solve this problem:

  1. List current versions and latest available versions of project packages:

    npm install -g npm-check-updates
    ncu
    
  2. Verify which versions you will need to upgrade / leave / degrade.

  3. To upgrade all the versions listed by the ncu command (this just edits the package.json file):

    ncu -u
    
  4. If it is necessary to degrade a package, locate the required versions with the command:

    npm view <package> versions
    
  5. Then, edit the package.json file by hand to configure the required versioning.

  6. Run npm install to update your installed packages and package-lock.json.

  7. Finally, depending on the debug process, and if the console indicates any additional version requirement, you can install specific versions:

    npm install <package>@<version>

First uninstall the current version of angular cli by running the following commands :-

      npm uninstall -g @angular/cli
      npm cache clean
      npm install -g @angular/cli`

This will install the latest version of angular cli i.e. 8.0. you can check it by running ng --version command .

Now add the material design package by running the following commands :-

npm install -s @angular/material @angular/cdk @angular/animations

Now build you application it will remove all the warnings.

Hope it will help.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!