1

How do I get Angular Material 2 to work with Angular 4?

  1. I re-installed Angular CLI and now it is at 1.0.0 using: npm install -g @angular/cli
  2. I created a new Angular 4 project using: ng new MyProject
  3. I tried to install Material 2 but it failed using: npm install --save @angular/material

+-- UNMET PEER DEPENDENCY @angular/[email protected]

+-- UNMET PEER DEPENDENCY @angular/[email protected]

+-- UNMET PEER DEPENDENCY @angular/[email protected]

-- @angular/[email protected]

Here is what I get when I do a ng -v for the project: @angular/cli: 1.0.0

node: 6.10.0

os: win32 x64

@angular/common: 4.0.0

@angular/compiler: 4.0.0

@angular/core: 4.0.0

@angular/forms: 4.0.0

@angular/http: 4.0.0

@angular/material: 2.0.0-beta.2

@angular/platform-browser: 4.0.0

@angular/platform-browser-dynamic: 4.0.0

@angular/router: 4.0.0

@angular/cli: 1.0.0

@angular/compiler-cli: 4.0.0

4 Answers 4

2

According to the Angular Material 2 Team it will be a few days until there is a new release that is compatible with Angular 4.

You can use the latest version from master:

npm install --save https://github.com/angular/material2-builds.git
Sign up to request clarification or add additional context in comments.

Comments

2

This question is kind of old but I stumbled upon it as I was just getting to work Angular with Material.

Installing the latest version of material2 will make it depend on Angular 5. If you want to get it to work with Angular 4 you can install the latest version before the breaking change:

npm install --save @angular/[email protected] @angular/[email protected]

2 Comments

Thank you for posting this, even if the question is old! As you pointed out, installing the latest version of Material doesn't work with Angular 4. And I was having a lot of trouble finding the correct version to be using. This has given me my answer!
Glad I could help.
1

Angular Material v2.0.0-beta.3 is now released. It depends on Angular 4. Go ahead, and install it.

npm i @angular/material --save

If you already used previous version of the package, you might want to perform some changes in your project, according to the CHANGELOG.md

Comments

0

As the previous answer stated, you can use the master as described in their readme on github.

I have been doing this for a while now, and it is a good solution since this project's realease schedule seems to have slowed to about once every 200-300 commits.

CAUTION, however, since these are basically their daily builds. Things get fixed, but sometimes things get broken as well. Even the build itself might be wonky (e.g. a few times they've left out all of the theming files). But if you go to the releases of the material2/builds project, you can get links to all of the past daily builds. That exact build can be referenced precisely in your package.json.

So if at first when you switch to master, everything breaks. Do not despair... yet. First go back to the builds for the last week or two and see if you can't make your project unbroken by linking directly to that one of them.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.