question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot read property '$moment' of undefined

See original GitHub issue

how to use nuxt moment?

i was added nuxt moment on module nuxt.config.js and i try to call moment on mounted() a page but has undefined $moment.

nuxt.config.js

modules: [
    ...
    '@nuxtjs/moment',
    ...
  ],

pages

mounted() {
    console.log(this.$moment) // undefined $moment
  },

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:10 (4 by maintainers)

github_iconTop GitHub Comments

6reactions
PayteRcommented, Aug 18, 2019

same error here, when i call function in template

{{ $moment(post.post_date).format('HH:mm') }} // works well

it works just fine, when it’s used in mounted() it’s fine too

  mounted: function() {
    console.log(this.$moment) // works well
  },

but when i want to use it in apollo query variable, then it’s undefined

apollo: {
    posts: {
      query() {
        return POSTS_QUERY
      },
      update: data => data.postsElastic,
      variables() {
        // Use vue reactive properties here
        return {
          date_after: this.$moment().format() // undefined
        }
      }
    }
  }
1reaction
teledirigidocommented, Feb 1, 2019

Make sure you did installed Nuxt Moment: yarn add moment @nuxtjs/moment OR npm i moment @nuxtjs/moment

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot read property 'moment' of undefined - Stack Overflow
I have a problem with momentjs and I have no idea why. I wrote this code a couple of days ago and it...
Read more >
can't use moment with vue.js - Laracasts
i am trying to use moment with vue.js at laravel project and i installed moment ... Error in render: "TypeError: Cannot read property...
Read more >
Problem with moment.js and datatable.js
Uncaught TypeError : Cannot read property 'moment' of undefined at HTMLDocument.<anonymous> (CPPListView?sfdc.tabName=01r4E000000DZav:11665)
Read more >
Moment.js - Maggie's Blog
Posts about Moment.js written by Maggie Pint. ... fromNow() //Uncaught TypeError: Cannot read property 'replace' of undefined. That didn't go well did it?...
Read more >
Moment Library not loading correctly - Esri Community
On load, I immediately get and error: 'Uncaught TypeError: Cannot read properties of undefined (reading 'tz')'. Researching this; I found an ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found