NuxtN
Nuxt12mo ago
IsaacR943

Bun not found in nuxt application?

This is the file im trying to apply on my app - route: utils/logger.vue
// utils/logger.vue
import Bun from 'bun';

const file = Bun.file("foo.log");
const writer = file.writer();

export { writer };


The code works, i do see the output in foo.log. However, after that the app crashes saying there is no module bun defined.
This is every weird and cant find documentation on the problem

implementation:
// pages/index.vue
<script setup lang="ts">
const route = useRoute()
import { writer } from '~/utils/logger'

async function testWrite() {
    await writer.write("We are at the index app");
    await writer.end(); // Don't forget to close the writer when done
}

testWrite();
</script>

<template>
  <div>
    <h1>Nuxt Routing set up successfully!</h1>
    <p>Current route: {{ route.path }}</p>
    <a href="https://nuxt.com/docs/getting-started/routing" target="_blank">Learn more about Nuxt Routing</a>
  </div>
</template>
Was this page helpful?