【发布时间】:2021-01-20 12:14:53
【问题描述】:
我在执行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_modules/time-ago-pipe/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
这就是我在app.module.ts 文件中使用它的方式
import { NgModule } from '@angular/core';
import {TimeAgoPipe} from 'time-ago-pipe';
@NgModule({
declarations: [
TimeAgoPipe
],
imports: [
FormsModule,
],
entryComponents: [LastseenDevicesComponent],
bootstrap: [ AppComponent ],
})
export class AppModule { }
我该如何解决这个问题?
【问题讨论】:
标签: angular ng-modules