node_modules / ng2-toastr / src / toast-container.component.d.ts(1,48)中的错误:TS2305- / node_modules / @ angular / core / core“'没有导出的成员

时间:2018-08-27 16:35:49

标签: node.js angular rxjs

我有最新版本的“ rxjs”:“ ^ 6.0.0”和@ angular / cli”:“〜6.0.8” 当我运行ng服务时,我收到以下编译错误- node_modules / ng2-toastr / src / toast-container.component.d.ts(1,48)中的错误:  / node_modules / @ angular / core / core“'没有导出的成员'AnimationTransitionEvent'。

以以下格式在我的app.module.ts中导入了toastermodule 从'ngx-toastr'导入{ToastrModule}; 也收到以下错误 错误TS2305:模块'“ C:/ Users / user1 / Sublime Text 3 / NodeJS / groupchat-application / node_modules / rxjs / Observable”'没有导出的成员'Observable'。 node_modules / rxjs / Observable.d.ts(1,15):错误TS2307:找不到模块“ rxjs-compat / Observable”。 如下所示导入到我的service.ts中 从“ rxjs”导入{可观察的,of};

请指导如何进行

4 个答案:

答案 0 :(得分:3)

您使用“ rxjs”:“ ^ 6.0.0” 和ng2-toastr:在6.0.0以下使用rxjs,因此存在兼容性问题。 您可以使用两种选择:

  1. rxjs兼容 rxjs 6.0.0

  2. 否则使用 ngx-toasta [link]

答案 1 :(得分:3)

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!');
  }
}

答案 2 :(得分:0)

我能够使用

解决此问题
        npm install ng6-toastr-notifications --save

有一个很好的文档链接。我将为您提供链接

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

答案 3 :(得分:0)

这个问题是由于 toastr 和动画与你的 angular 版本兼容!

   ngx-toastr   Angular
    6.5.0       4.x
    8.10.2      5.x
    10.1.0      8.x 7.x 6.x
    11.3.3      8.x
    12.1.0      9.x
   current  >= 10.x

为您的情况尝试这些版本:

如果你的项目中有 toastr 和 animation,首先卸载它们,然后运行它们:

<块引用>

npm install ngx-toastr@10.0.4 --save

<块引用>

npm install @angular/animations@8.2.14 --save

相关问题