Angular 无法声明';TimeAgoPipe';在一个NGO模块中,因为它';这不是当前汇编的一部分
在执行Angular 无法声明';TimeAgoPipe';在一个NGO模块中,因为它';这不是当前汇编的一部分,angular,ng-modules,Angular,Ng Modules,在执行ng build--prod时,Angular 10中出现错误。它在ng build中工作 ERROR in src/app/app.module.ts:44:5 - error NG6001: Cannot declare 'TimeAgoPipe' in an NgModule as it's not a part of the current compilation. 44 TimeAgoPipe, ~~~~~~~~~~~ node_modules/ti
ng build--prod
时,Angular 10
中出现错误。它在ng build
中工作
ERROR in src/app/app.module.ts:44:5 - error NG6001: Cannot declare 'TimeAgoPipe' in an NgModule as it's not a part of the current compilation.
44 TimeAgoPipe,
~~~~~~~~~~~
node_modules/time-ago-pipe/time-ago.pipe.d.ts:3:22
3 export declare class TimeAgoPipe implements PipeTransform, OnDestroy {
~~~~~~~~~~~
'TimeAgoPipe' is declared here.
这是node\u模块/time-ago管道/time-ago.pipe.d.ts中的文件
import { PipeTransform, NgZone, ChangeDetectorRef, OnDestroy } from "@angular/core";
import * as ɵngcc0 from '@angular/core';
export declare class TimeAgoPipe implements PipeTransform, OnDestroy {
private changeDetectorRef;
private ngZone;
private timer;
constructor(changeDetectorRef: ChangeDetectorRef, ngZone: NgZone);
transform(value: string): string;
ngOnDestroy(): void;
private removeTimer();
private getSecondsUntilUpdate(seconds);
static ɵfac: ɵngcc0.ɵɵFactoryDef<TimeAgoPipe, never>;
static ɵpipe: ɵngcc0.ɵɵPipeDefWithMeta<TimeAgoPipe, "timeAgo">;
}
//# sourceMappingURL=time-ago.pipe.d.ts.map
如何修复此问题?将
TimeAgoPipe
添加到导出应用程序模块的数组中。此软件包已三年未维护,我建议使用,您可以在此处找到有关此问题的更多详细信息
这个解决方案对一些人有效
...
import { TimeAgoPipe } from 'time-ago-pipe';
@Pipe({
name: 'timeAgo',
pure: false
})
export class TimeAgoExtendsPipe extends TimeAgoPipe {}
@NgModule({
declarations: [
TimeAgoExtendsPipe,
...
在app.module.ts
中,似乎没有export
数组。您可以像imports
一样添加exports
数组。尝试了此操作,但出现了相同的错误exports:[TimeAgoPipe],
。
...
import { TimeAgoPipe } from 'time-ago-pipe';
@Pipe({
name: 'timeAgo',
pure: false
})
export class TimeAgoExtendsPipe extends TimeAgoPipe {}
@NgModule({
declarations: [
TimeAgoExtendsPipe,
...