Search code examples
vue.jsnuxt.jsmomentjs

Nuxt.js with vue-moment


I'm using vue-moment and it works perfectly, although i get an error in console

[Vue warn]: Failed to resolve filter: moment

What i'm doing:

plugins/moment.js

    import VueMoment from 'vue-moment'
    import Vue from 'vue'
    Vue.use(VueMoment)

nuxt.config.js

  plugins: [
    { src: '~/plugins/moment.js', mode: 'client' }
  ],

Vue-moment works just fine, but the error appears.


Solution

  • You should probably pass on using Moment since it deprecated itself: https://momentjs.com/docs/#/-project-status/

    Rather using the module for date-fns, which is pretty simple to install and use: https://github.com/nuxt-community/date-fns-module