Greg Finzer
Greg Finzer

Reputation: 7054

Install Angular Material 2 with Angular 4 Unmet Dependency

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

Upvotes: 1

Views: 2860

Answers (4)

larsl
larsl

Reputation: 358

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]

Upvotes: 2

matewka
matewka

Reputation: 10148

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

Upvotes: 1

IndyWill
IndyWill

Reputation: 2945

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.

Upvotes: 0

Greg Finzer
Greg Finzer

Reputation: 7054

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

Upvotes: 2

Related Questions