Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

eskiesirius's avatar

Cant Install moment()

How to apply moment in inertia?

0 likes
8 replies
tykus's avatar

In the resources/js/app.js (comments for brevity) and assuming you have installed moment using NPM/yarn

import moment from "moment";
// ...
createInertiaApp({
	// ..
    setup({ el, app, props, plugin }) {
        return createApp({ render: () => h(app, props) })
			// ...
            .mixin({ methods: { route, moment} })
           // ...
            .mount(el);
    },
})
1 like
tykus's avatar

@eskiesirius just use the moment function in the component; it is mixed into the Vue app

eskiesirius's avatar

@tykus yeah i tried but it didn't worked.. Uncaught (in promise) ReferenceError: moment is not defined error..

eskiesirius's avatar

@tykus i mean using your method to use the moment as global didn't worked.. what i did was i just import the moment directly to the component..

Please or to participate in this conversation.