themesberg / themesberg/flowbite
500 error when using Flowbite with Nuxt.js 3 and Tailwind on development environment. Production no 500 error.
Nobody has claimed this yet.
- Dominant language
- HTML
- Stars
- 9.4k
- Forks
- 862
- PR merge metrics
- No merged PRs in 30d
Description
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.
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>
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:
- Setup a new Nuxt.js 3 project
- Follow the documentation on https://flowbite.com/docs/getting-started/nuxt-js/
- Edit the
app.vuefile and add the Sidebar vue/html code - Add the Flowbite JS code https://flowbite.com/docs/getting-started/quickstart/
- Run
yarn dev
500 error occurs
- If you run
yarn build && node .output/server/index.mjsthe 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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the app.vue reproduction and the Nuxt.js setup from the linked Flowbite documentation. Run yarn dev with the initFlowbite import and inspect the stack trace at node_modules/flowbite-datepicker/dist/main.cjs.js and flowbite/src/components/datepicker/index.ts. Done means the development server no longer returns a 500 error while the production command remains working.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- nuxtjs, tailwindcss
- Domain
- frontend, web-dev
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100