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.

"ReferenceError: moment is not defined"

See original GitHub issue

I’m wondering how people are getting this to work. I am building an app with Laravel and Vue.

In my app.js I import Moment:

import Moment from 'vue-moment';
Vue.use( Moment );

Then in my component:

    methods : {

        date : function( timestamp ) {

            return moment( timestamp );

        }

    }

Which results in:

"ReferenceError: moment is not defined"

I also tried Vue.use(require('vue-moment')); and different combinations of upper/lowercase. Any clue?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:11

github_iconTop GitHub Comments

1reaction
BrockReececommented, Dec 29, 2021

@fairking I have updated the readme in #163 while I test including the type definitions as part of this package

1reaction
BrockReececommented, Apr 15, 2020

The moment instance is added to the prototype of a Vue and so can be accessed like this in your Vue component.

methods : {
  date(timestamp) {
    return this.$moment( timestamp )
  }
}

This is explained at the bottom of the readme and should still be working as intended. https://github.com/brockpetrie/vue-moment#thismoment

But if all you need is to return some formatted timestamps and not use any of the additional filter functionality, it sounds like using vanila moment.js will probably work best for you.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Reference Error: moment is not defined (Using moment.js)
I have a folder that i've installed moment.js into (npm install moment) and i'm running my program (node isDate.js). import {moment} from ' ......
Read more >
"Uncaught ReferenceError: moment is not defined" using NPM
I installed Moment.js using npm: npm install moment. I'd now like to compile it using npm run ... "Uncaught ReferenceError: moment is not...
Read more >
ReferenceError: moment is not defined · Issue #4572 - GitHub
I've use the latest version of moment js and include the minified js at the top of my script. Most of the time...
Read more >
Uncaught ReferenceError: moment is not defined
Hi! After updating to EA 2.3.5 I'm getting errors in the console like the ones below. The interesting thing is that it only...
Read more >
[Solved]-"moment is not defined" using moment.js-moment.js
Related Query · moment is not defined - trying to reference moment function using ejs · Reference Error: moment is not defined (Using...
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