themesberg / themesberg/flowbite

500 error when using Flowbite with Nuxt.js 3 and Tailwind on development environment. Production no 500 error.

Open
#958 1 comment 0 reactions 0 assignees View on GitHub

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:

  1. Setup a new Nuxt.js 3 project
  2. Follow the documentation on https://flowbite.com/docs/getting-started/nuxt-js/
  3. Edit the app.vue file and add the Sidebar vue/html code
  4. Add the Flowbite JS code https://flowbite.com/docs/getting-started/quickstart/
  5. Run yarn dev

500 error occurs

  1. 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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.