If you do want to use moment specifically (I have been using it in my projects, mostly because I didn’t know of the existence of date-fns so I went with moment and it’s working fine for what I need).
Install the node package
npm install moment --save
// this part is probably optional if you don’t need translations
Import into app.component.ts
import moment from 'moment';
Set locale on platform ready
moment.locale('en');
Import into any components you need and start using it
this.timeAgo = moment.utc(this.note.created_at).fromNow();