I have used nuxt.js as web apps framework and UI framework is Vuetify.js. I thought checking file existence of my web apps to use "fs.existsSync" of node.js, but it didn't work. I tried to test like below.
<template>
<div>
<v-btn @click="test">fileCheck
</v-btn>
</div>
</template>
<script lang="ts">
import {Component, Vue} from 'nuxt-property-decorator'
const fs = require('fs')
@Component({})
export default class extends Vue {
test() {
const url = './static/test.png'
if (fs.existsSync(url)) {
alert('exist!')
} else {
alert('Not exist!')
}
}
}
</script>
this code is really simple, I just click the botton and show the alert to notice file exist or not. But never happen and error occurred like.
client.js?06a0:97 TypeError: fs.existsSync is not a function
Does any give me advise, please?