Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ERROR in node_modules/ng2-toastr/src/toast-container.component.d.ts(1,48): TS2305- /node_modules/@angular/core/core"' has no exported member

I have the latest version of "rxjs": "^6.0.0" and @angular/cli": "~6.0.8" When i run ng serve i am receiving below compilation error-

ERROR in node_modules/ng2-toastr/src/toast-container.component.d.ts(1,48): 
 /node_modules/@angular/core/core"' has no exported member'AnimationTransitionEvent'.

imported toastermodule in the below format in my app.module.ts
import {ToastrModule} from 'ngx-toastr';

Also receiving below error

error TS2305: Module '"C:/Users/user1/Sublime Text 3/NodeJS/groupchat-application/node_modules/rxjs/Observable"' has no exported member 'Observable'.
node_modules/rxjs/Observable.d.ts(1,15): error TS2307: Cannot find module 'rxjs-compat/Observable'.
imported as below in  My service.ts
import { Observable, of} from "rxjs"; 

Please guide on how to proceed

like image 913
Priyanka K Avatar asked Aug 27 '18 16:08

Priyanka K


3 Answers

Use **ngx-toastr**

**steps to follow**

Install dependencies 

1)npm install ngx-toastr --save
2)npm install @angular/animations --save

3)Add CSS to your angular.json file
"styles": [
  "styles.scss",
  "node_modules/ngx-toastr/toastr.css" // try adding '../' if you're using angular cli before 6
]

4)Add toastr module to your app.module.ts
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { ToastrModule } from 'ngx-toastr';

@NgModule({
  imports: [BrowserAnimationsModule,
    ToastrModule.forRoot() 
})

5) Add toastr service to your desired component 

import { ToastrService } from 'ngx-toastr';

@Component({...})
export class YourComponent {
  constructor(private toastr: ToastrService) {}

  showSuccess() {
    this.toastr.success('Hello world!', 'Toastr fun!');
  }
}
like image 178
Sumit Tiwari Avatar answered Oct 02 '22 17:10

Sumit Tiwari


You use "rxjs": "^6.0.0" and ng2-toastr: uses rxjs below 6.0.0 so compatibiliy issue is there. You have two options to use :

  1. rxjs-compat with rxjs 6.0.0

  2. Else use ngx-toasta [link]

Edit: Due to the update of angular and its dependency not in sync and if you are using angular material 6+ then you can go for @angular/material Snackbar which is better compatible with the latest version of Angular.

like image 36
AlokeT Avatar answered Oct 02 '22 18:10

AlokeT


i was able to solve this problem using

        npm install ng6-toastr-notifications --save

a good documentation link is available .i will provide u the link

https://www.npmjs.com/package/ng6-toastr-notifications

like image 33
Jai krish Avatar answered Oct 02 '22 17:10

Jai krish