2

I'm trying to install angular2-flash-messages to my angular-src, not to the root. then I tried with npm install angular2-flash-messages. then it returns this,

├── UNMET PEER DEPENDENCY @angular/core@2.4.10
└── angular2-flash-messages@1.0.7 

then I tried to resolve this with installing rxjs and angluar/cli globally. But it didn't work. How do I fix this?

there is a warning : npm WARN angular2-flash-messages@1.0.7 requires a peer of @angular/core@^4.0.0 but none was installed.

eko
  • 39,722
  • 10
  • 72
  • 98
Jobs
  • 269
  • 2
  • 6
  • 21

2 Answers2

2

It means that that version of angular2-flash-messages uses @angular/core version 4.0.0^. Your project might still work but that's the recommended version. If there are any breaking changes in the peer library your app might crash so it's recommended to install the correct peer dependencies.

eko
  • 39,722
  • 10
  • 72
  • 98
  • yep, but when I `import` the module like this `import { FlashMessageModule} from 'angular2-flash-messages';`, it gives me an error – Jobs Mar 31 '17 at 05:24
  • @harnish how could I've guessed that if you don't include it in your question :/ ? What does the error say? – eko Mar 31 '17 at 05:26
  • uh, sorry about that. it says cannot find that module – Jobs Mar 31 '17 at 05:27
  • @harnish Have you done all the things listed here https://www.npmjs.com/package/angular2-flash-messages ? Do you have that lib inside your node_modules? Can you include a screenshot with the relevant info. – eko Mar 31 '17 at 05:29
  • yep I did everything on it – Jobs Mar 31 '17 at 05:31
  • @harnish can you add the relevant things to your question? Like the way it is right now the question doesn't involve the things you mentioned. – eko Mar 31 '17 at 05:35
0

You try import by:

import {FlashMessagesModule} from 'angular2-flash-messages/module';

constructor(
....
public flashMessage:FlashMessagesService
) { }

logout() {
    ...
    this.flashMessage.show('Your message', {cssClass: 'alert-success', timeout: 3000});
}

This working for me.

Dũng IT
  • 2,751
  • 30
  • 29