You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've created a Nuxt.js + Tailwind app according to the documentation here https://flowbite.com/docs/getting-started/nuxt-js/. When running the project locally using yarn dev I get the following error.
ERROR document is not defined
at Object.<anonymous> (node_modules/flowbite-datepicker/dist/main.cjs.js:595:13)
at Module._compile (node:internal/modules/cjs/loader:1469:14)
at Object..js (node:internal/modules/cjs/loader:1548:10)
at Module.load (node:internal/modules/cjs/loader:1288:32)
at Function._load (node:internal/modules/cjs/loader:1104:12)
at Module.require (node:internal/modules/cjs/loader:1311:19)
at require (node:internal/modules/helpers:179:18)
at Object.<anonymous> (node_modules/flowbite/src/components/datepicker/index.ts:8:1)
at Module._compile (node:internal/modules/cjs/loader:1469:14)
at Object..js (node:internal/modules/cjs/loader:1548:10)
WARN [nuxt] Failed to stringify dev server logs. Received DevalueError: Cannot stringify arbitrary non-POJOs. You can define your own reducer/reviver for rich types following the instructions in https://nuxt.com/docs/api/composables/use-nuxt-app#payload.
It appears this is from the following line of codeimport { initFlowbite } from "flowbite";.
<script setup>
import { onMounted } from "vue";
// error occurs when running this line of code. Commenting the code fixes the 500 error
import { initFlowbite } from "flowbite";
// initialize components based on data attribute selectors
onMounted(() => {
initFlowbite();
});
</script>
If you run yarn build && node .output/server/index.mjs the error does not occur.
Expected behavior
No 500 error should occur
Screenshots
No screen shots.
Desktop (please complete the following information):
MacOS 12.2.1
Chrome 127.0.6533.122
Arm 64
The text was updated successfully, but these errors were encountered:
jamie3
changed the title
500 error when using Flowbite with Nuxt.js 3
500 error when using Flowbite with Nuxt.js 3 and Tailwind on development environment. Production no 500 error.
Sep 11, 2024
It appears the Nuxt 3 Starter template is outdated. In the documentation it is stated you have to initialize when the component gets mounted it looks like it's not enough to use onMounted because it is possible that document is not available e.g. during SSR. The following steps worked for me (flowbite 2.5.1):
Create a flowbite composable as suggested in the docs
Describe the bug
I've created a Nuxt.js + Tailwind app according to the documentation here https://flowbite.com/docs/getting-started/nuxt-js/. When running the project locally using
yarn dev
I get the following error.It appears this is from the following line of code
import { initFlowbite } from "flowbite";
.The HTML code
app.vue
contains the Flowbite sidebar https://flowbite.com/docs/components/sidebar/When running this in production using
yarn build && node .output/server/index.mjs
the 500 error does not appear.To Reproduce
Steps to reproduce the behavior:
app.vue
file and add the Sidebar vue/html codeyarn dev
500 error occurs
yarn build && node .output/server/index.mjs
the error does not occur.Expected behavior
No 500 error should occur
Screenshots
No screen shots.
Desktop (please complete the following information):
The text was updated successfully, but these errors were encountered: