Trying to use moment.js gives error

I’m trying to use the moment.js library in a custom:button-card template, but it always throws an error saying: e is undefined.
The fact is that it is a configuration that I copied from other user, and I saw that another custom card (clock) uses it. But I don’t know what’s the problem in my install.
The library is imported in resources as a js module.

  show_label: true
  triggers_update: all
  label: |
      var diff = (new Date() - new Date(entity.last_changed)) / 1000 / 60
      if (isNaN(diff)) { return 'Unknown' }
      if (diff <= 0.05) { return 'Just now' }
      else if (diff <= 1) { return Math.round(diff * 60) + ' seconds ago' }
      else { return moment(entity.last_changed).fromNow() }

This is the resource:[email protected]/min/moment.min.js

The lovelace is in storage mode, so in theory resources should be added in the gui…

  mode: storage
  dashboards: !include lovelace-dashboards.yaml