time-ago-pipe icon indicating copy to clipboard operation
time-ago-pipe copied to clipboard

ERROR in No Pipe decorator found on TimeAgoPipe

Open ivissani opened this issue 6 years ago • 28 comments

I've got the aforementioned error when running ng serve --aot Angular version is 5.1.1.

No error when serving with just ng serve

ivissani avatar May 05 '18 13:05 ivissani

I am having the same issue, without fix.

heintj avatar May 16 '18 13:05 heintj

i too am having issue

safaldas avatar May 22 '18 06:05 safaldas

Same issue, any ideas?

danduh avatar May 25 '18 12:05 danduh

same issue

freemanlam avatar May 31 '18 02:05 freemanlam

Issue still persists.

SharmaTushar avatar Jun 06 '18 13:06 SharmaTushar

Got this issue when upgrading to angular 6

AntonisFK avatar Aug 23 '18 23:08 AntonisFK

Same issue.

EDIT: Workaround for me was to just copy the source code and to create the file in my project.

druvisc avatar Sep 11 '18 08:09 druvisc

same issue

rvuyyuru1 avatar Sep 11 '18 18:09 rvuyyuru1

+1

jiboune avatar Sep 19 '18 16:09 jiboune

same issue.

maybe this will help, but this is for older version of this lib. https://stackoverflow.com/questions/47119135/cannot-determine-the-module-for-component-angular-5

hbarve1 avatar Sep 29 '18 05:09 hbarve1

+1

JonesM87 avatar Oct 02 '18 15:10 JonesM87

Same for me

IshanBhuta avatar Oct 18 '18 08:10 IshanBhuta

Same error.

DejanNemet avatar Oct 23 '18 08:10 DejanNemet

same issue.

AnilBhandare09 avatar Nov 15 '18 06:11 AnilBhandare09

same issue.

ayoubchebbi avatar Nov 20 '18 21:11 ayoubchebbi

Same issue with Angular 6.1.10

nijat12 avatar Dec 10 '18 15:12 nijat12

same issue

jjgriff93 avatar Dec 24 '18 17:12 jjgriff93

Same here :(

crufter avatar Jan 21 '19 18:01 crufter

yes

[image: Mailtrack] https://mailtrack.io?utm_source=gmail&utm_medium=signature&utm_campaign=signaturevirality5& Sender notified by Mailtrack https://mailtrack.io?utm_source=gmail&utm_medium=signature&utm_campaign=signaturevirality5& 21/01/19 à 22:33:25

Le lun. 21 janv. 2019 à 19:12, Cruft King [email protected] a écrit :

Same here :(

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/AndrewPoyntz/time-ago-pipe/issues/22#issuecomment-456159722, or mute the thread https://github.com/notifications/unsubscribe-auth/ARIk3R49t3esDLbNXgXL-leXv8hTS9Xlks5vFgMcgaJpZM4Tzoy4 .

ayoubchebbi avatar Jan 21 '19 21:01 ayoubchebbi

Same issue.

I suggest everyone ngx-timeago it's better, I found my solution with this one

etsraphael avatar Apr 30 '19 16:04 etsraphael

What is the fix ?

tolotrasamuel avatar Sep 01 '19 08:09 tolotrasamuel

You can fix this by adding the missing decorator, add this line:

@Pipe({ name: 'timeAgo' })

above the export line in the module source code, time-ago.pipe.d.ts

JonesM87 avatar Sep 24 '19 09:09 JonesM87

Still seeing this issue with Ang 8, and the above didn't work for me.

shannon-kay avatar Nov 26 '19 16:11 shannon-kay

I also faced this issue and fixed by @JonesM87's suggestion.

ajaysarw avatar Jan 10 '20 08:01 ajaysarw

still seeing this cant find a workaround.

ng serve - always works, but a save to any source file when it recompiles and I get the error.

strangely, only started happening after I inadvertently upgraded to Angular 9 and then had to uninstall and go back to angular 8.

JSX001 avatar Feb 12 '20 15:02 JSX001

still seeing this cant find a workaround.

ng serve - always works, but a save to any source file when it recompiles and I get the error.

strangely, only started happening after I inadvertently upgraded to Angular 9 and then had to uninstall and go back to angular 8.

Same issue here. I upgraded to Angular 9 yesterday and am getting this error on my local development web server (http://localhost:4200) ... I can run "ng serve" but if I change a file and it recompiles in response to me pressing "save" in my editor, this error appears: image

In order to get going again, I have to kill the process and do a "ng serve" again, which takes a while. I'm probably going to have to comment out TimeAgo code for now until a fix is found. Luckily it's not referenced a whole lot, but would love to be able to reimplement it.

mikejoseph23 avatar Feb 14 '20 20:02 mikejoseph23

same issue here, ng serve works fine, but on any change in any file, upon recompilation, this error throws back. Any solution ?

kuldeeps1ngh avatar Mar 30 '20 05:03 kuldeeps1ngh

Hey guys certainly not best solution but it's work fine. Rewrite pipe class and export it. Something like this :

import { Pipe, PipeTransform, NgZone, ChangeDetectorRef, OnDestroy } from '@angular/core';

@Pipe({
  name: 'timeAgo',
  pure: false
})
export class TimeAgoExtPipe implements PipeTransform, OnDestroy {
  changeDetectorRef: ChangeDetectorRef;
  ngZone: NgZone;
  timer: any;

  constructor(changeDetectorRef: ChangeDetectorRef, ngZone: NgZone) {
    this.changeDetectorRef = changeDetectorRef;
    this.ngZone = ngZone;
  }

  ngOnDestroy() {
    this.removeTimer();
  }

  transform(value: any, args?: any): any {
    this.removeTimer();
    const d = new Date(value);
    const now = new Date();
    const seconds = Math.round(Math.abs((now.getTime() - d.getTime()) / 1000));
    const timeToUpdate = (Number.isNaN(seconds)) ? 1000 : this.getSecondsUntilUpdate(seconds) * 1000;
    this.timer = this.ngZone.runOutsideAngular(() => {
      if (typeof window !== 'undefined') {
        return window.setTimeout(() => {
          this.ngZone.run(() => this.changeDetectorRef.markForCheck());
        }, timeToUpdate);
      }
      return null;
    });
    const minutes = Math.round(Math.abs(seconds / 60));
    const hours = Math.round(Math.abs(minutes / 60));
    const days = Math.round(Math.abs(hours / 24));
    const months = Math.round(Math.abs(days / 30.416));
    const years = Math.round(Math.abs(days / 365));
    if (Number.isNaN(seconds)) {
      return '';
    } else if (seconds <= 45) {
      return 'a few seconds ago';
    } else if (seconds <= 90) {
      return 'a minute ago';
    } else if (minutes <= 45) {
      return minutes + ' minutes ago';
    } else if (minutes <= 90) {
      return 'an hour ago';
    } else if (hours <= 22) {
      return hours + ' hours ago';
    } else if (hours <= 36) {
      return 'a day ago';
    } else if (days <= 25) {
      return days + ' days ago';
    } else if (days <= 45) {
      return 'a month ago';
    } else if (days <= 345) {
      return months + ' months ago';
    } else if (days <= 545) {
      return 'a year ago';
    } else {
      // (days > 545)
      return years + ' years ago';
    }
  }

  removeTimer() {
    if (this.timer) {
      window.clearTimeout(this.timer);
      this.timer = null;
    }
  }

  getSecondsUntilUpdate(seconds) {
    const min = 60;
    const hr = min * 60;
    const day = hr * 24;

    if (seconds < min) {
      // less than 1 min, update every 2 secs
      return 2;
    } else if (seconds < hr) {
      // less than an hour, update every 30 secs
      return 30;
    } else if (seconds < day) {
      // less then a day, update every 5 mins
      return 300;
    } else {
      // update every hour
      return 3600;
    }
  }
}

and in app.module.ts

import { TimeAgoExtPipe } from './_pipes/time-ago-ext.pipe';

finally replace TimeAgo pipe module by yours.

BenjaminPoutriquet35800 avatar Apr 09 '20 14:04 BenjaminPoutriquet35800