moff / angular2-flash-messages

Angular 2 flash messages module
52 stars 21 forks source link

FlashMessagesModule is not an NgModule #9

Closed sbroways closed 7 years ago

sbroways commented 7 years ago

Flash Messages had been working fine on my app and then suddenly started throwing an error: FlashMessagesModule is not an NgModule errors @ client?93b6:80 sock.onmessage @ socket.js:37 EventTarget.dispatchEvent @ eventtarget.js:51 (anonymous) @ main.js:274 SockJS._transportMessage @ main.js:272 EventEmitter.emit @ emitter.js:50 WebSocketTransport.ws.onmessage @ websocket.js:35 wrapFn @ zone.js:889 ZoneDelegate.invokeTask @ zone.js:275 Zone.runTask @ zone.js:151 ZoneTask.invoke @ zone.js:345

I've tried importing using both: import { FlashMessagesModule } from 'angular2-flash-messages'; and: import { FlashMessagesModule } from 'angular2-flash-messages/module';

I followed the directions here for installation. Thanks for help.

gchorus commented 7 years ago

Same after upgrading Angular to 2.4.1 and typescript to 2.0.3.

sbroways commented 7 years ago

This appears to be an issue with multiple angular components.

I'm going to try switching from Typings to @types/ and see if that resolves my issue.

ghost commented 7 years ago

Same problem. Using Angular 2.3.1 and typescript 2.0.3

moff commented 7 years ago

Sorry for the delay, folks. At the moment I'm traveling so I don't have time and opportunity to fix this issue. I'll take a look when I'll get back home. Sorry for that!

rdbhagat999 commented 7 years ago

Same issue appears with @angular/cli version 1.0.0

seipekm commented 7 years ago

i'm also

cattalin commented 7 years ago

it temporarily worked when I reinstalled it npm install angular2-flash-messages --save, now it doesn't again, and reinstalling doesn't help. I just upgraded to angular 4 a few days ago, but it worked until now

sp01010011 commented 7 years ago

I have also just noticed this error, everything is working fine under dev env, however, once i attempt to compile the application it throw this error during the build process... any help is appreciated.

Here is my ng environment: @angular/cli: 1.0.0 node: 7.3.0 os: darwin x64 @angular/common: 4.0.1 @angular/compiler: 4.0.1 @angular/core: 4.0.1 @angular/forms: 4.0.1 @angular/http: 4.0.1 @angular/platform-browser: 4.0.1 @angular/platform-browser-dynamic: 4.0.1 @angular/router: 4.0.1 @angular/cli: 1.0.0 @angular/compiler-cli: 4.0.1

raman-chand commented 7 years ago

Update: I retried installing the latest angular2-flash-messages (1.0.7), and figured to change the private variable in my component's constructor from "constructor(private _flashMessagesService: FlashMessagesService)" to "constructor(private flashMessagesService: FlashMessagesService)." I copied the constructor's syntax from the angular2-flash-messages npm package webpage, and simply deleted the underscore before flash. Also, I added to my app.component.html the element to identify where the flash messages would appear on my website. It works perfectly! Hope this helps!

I also upgraded my angular to 4.0.0 and installed the latest angular2-flash-messages (1.0.7), and faced the exact same error of "FlashMessagesModule is not an NgModule." So, I tried downgrading my angular2-flash-messages to version 1.0.5 only, and it seems to work fine. I do, however, get a few warnings that says that this version of angular2-flash-messages requires a peer of angular 2.4.10, basically a version below 4.0.0. I'll post any future errors that I encounter because of it, too.

ZiedChekir commented 7 years ago

@raman-chand i removed the underscore before flashMessagesServices as you said. then i did flashMessagesServices.show in ngOnInit() but i still got the same Error. just refreshed the page and all worked fine. i really don't know what happend. i still get the error but everything works :c

raman-chand commented 7 years ago

@ZiedChekir so I don't have any input in my ngOnit(){}. It's empty. I read on the angular2-flash-messages npm documentation that we needed to include flash messages as a private variable as a parameter in the constructor. So: constructor(private flashMessage: FlashMessagesService){} - is how I wrote it - in the component you're inputting flash messages module into, in addition to the import command. When you do this.flashMessagesServices.show(), is "flashMessagesServices" the name of the private variable you created? I'd check the spelling.

Also, I still have a buggy experience with the latest flash messages in angular 2, so it's not totally resolved.

ZiedChekir commented 7 years ago

i was just experimenting with NgOnInit(). the spelling doesnt matter with underscore or without it. i actually still get the Error FlashMessagesModule is not an NgModule any time i ng serve but it is ignored when the page is refreshed. i agree that you something is still buggy but hope we will find a sollution

itssadon commented 7 years ago

Also getting the same error. How do I fix this?

ramonvermeulen commented 7 years ago

Having exact the same error, the weird thing is when I change 1 line of code in my editor and save the file again I don't have the error when it recompiles.

`> ng serve

As a forewarning, we are moving the CLI npm package to "@angular/cli" with the next release, which will only support Node 6.9 and greater. This package will be officially deprecated shortly after.

To disable this warning use "ng set --global warnings.packageDeprecation=false".

fallbackLoader option has been deprecated - replace with "fallback" loader option has been deprecated - replace with "use" fallbackLoader option has been deprecated - replace with "fallback" loader option has been deprecated - replace with "use" fallbackLoader option has been deprecated - replace with "fallback" loader option has been deprecated - replace with "use" fallbackLoader option has been deprecated - replace with "fallback" loader option has been deprecated - replace with "use" NG Live Development Server is running on http://localhost:4200. Hash: 7cbe0ff3bb1e02e8e0c0 Time: 12615ms chunk {0} polyfills.bundle.js, polyfills.bundle.map (polyfills) 231 kB {4} [initial] [rendered] chunk {1} main.bundle.js, main.bundle.map (main) 33.5 kB {3} [initial] [rendered] chunk {2} styles.bundle.js, styles.bundle.map (styles) 9.71 kB {4} [initial] [rendered] chunk {3} vendor.bundle.js, vendor.bundle.map (vendor) 2.59 MB [initial] [rendered] chunk {4} inline.bundle.js, inline.bundle.map (inline) 0 bytes [entry] [rendered]

ERROR in FlashMessagesModule is not an NgModule webpack: Failed to compile. Here I did edit 1 file and hit save again webpack: Compiling... Hash: 7cbe0ff3bb1e02e8e0c0 Time: 2431ms chunk {0} polyfills.bundle.js, polyfills.bundle.map (polyfills) 231 kB {4} [initial] chunk {1} main.bundle.js, main.bundle.map (main) 33.5 kB {3} [initial] chunk {2} styles.bundle.js, styles.bundle.map (styles) 9.71 kB {4} [initial] chunk {3} vendor.bundle.js, vendor.bundle.map (vendor) 2.59 MB [initial] chunk {4} inline.bundle.js, inline.bundle.map (inline) 0 bytes [entry] webpack: Compiled successfully.`

raman-chand commented 7 years ago

Gabriel Amazonas Mesquita wrote a great solution to the problem: http://stackoverflow.com/a/43214791

moff commented 7 years ago

@sbroways I've just tested latest package version(1.0.8) with Angular CLI and it works fine. Let me know, if you still experience this issue

sbroways commented 7 years ago

It's resolved. Thank you!

moff commented 7 years ago

Thanks to all for a feedback!

hammad100748 commented 7 years ago

Hi @moff i have installed npm angular 2 flash messages but its not integrating in my project compiler says cant resolve flashmessagesmodule error

Ankittiwari084 commented 6 years ago

I have latest version of angular2-flash-messages module but I am still facing bellow problem. ERROR TypeError: this.flashMessagesService.show is not a function Please help me.

pawanmeshram commented 6 years ago

I am getting an error "ERROR TypeError: this._flashMessagesService.show is not a function". I am using version "2.0.8" with angular-cli version 4.0.0.

Please help.

matyukirank commented 6 years ago

Please fix this issue, thanks in advance

aZolo77 commented 6 years ago

"ERROR TypeError: this._flashMessagesService.show is not a function" - same error!

ArtemBugriy commented 4 years ago

"FlashMessagesModule.forRoot returns a ModuleWithProviders type without a generic type argument." - Angular CLI version: 9.0.3