When trying to use moment() in my Vuejs application, I attempted declaring it as follows :
methods: {
moment: function () {
return moment();
}
},
I also tried testing it like this :
beforeMount() {
console.log(moment().format('MMMM Do YYYY, h:mm:ss a'))
},
However, I encountered the following error:
[Vue warn]: Error in beforeMount hook: "ReferenceError: moment is not defined"
Do I need to add moment to my package.json and run yarn install?
I want to keep it lightweight since I'll only be using moment() on one page of my application and do not want to load it on every page. Any suggestions would be appreciated.
Please advise,