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

JoshMountain's avatar

Function not working with <script setup>

I'm in a more or less default Laravel app with Vue and Inertia and I'm trying to use the 'filesize' NPM package. Here is my component:

<script setup>
import { Head } from '@inertiajs/inertia-vue3';
import { ref } from 'vue';
import { filesize } from 'filesize/lib/filesize.es6.js';

defineProps({
    file: {
        type: Object,
    },
});

</script>

<template>
    <Head title="File Show" />

    <p>File Size: {{ filesize(file.bytes) }}</p>
</template>

And for some reason I'm getting TypeError: $setup.filesize is not a function

0 likes
2 replies
rodrigo.pedra's avatar
Level 56

have you tried?

import filesize from 'filesize';
1 like

Please or to participate in this conversation.