tailwindlabs / tailwindui-issues

A place to report bugs discovered in Tailwind UI.
234 stars 4 forks source link

Protocol Template #1492

Closed AbbasSrour closed 1 year ago

AbbasSrour commented 1 year ago

What component (if applicable)

Describe the bug A number of bugs are being raised when you try to run or build the template, the main issue was next "use client;". Been debugging it for the last couple of days and after doing a lot of changes (one of them updating everything to last version) and then going back and reverting them one by one, the issue was back again when I reverted the package.json to the previous original version.

Here is the current package json that works for me, I can't go back and check which dependency exactly is causing the issue because I have little time left, but I have already checked that the bump in next package was not it. Here is a screen shot of the package changes:

Screenshot from 2023-08-15 14-28-29

and here is the new package json

{
  "name": "tailwindui-protocol",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "dev": "next dev",
    "build": "next build",
    "start": "next start",
    "lint": "next lint"
  },
  "browserslist": "defaults, not ie <= 11",
  "dependencies": {
    "@algolia/autocomplete-core": "^1.10.0",
    "@headlessui/react": "^1.7.16",
    "@headlessui/tailwindcss": "^0.2.0",
    "@mdx-js/loader": "^2.3.0",
    "@mdx-js/react": "^2.3.0",
    "@next/mdx": "^13.4.13",
    "@sindresorhus/slugify": "^2.2.1",
    "@tailwindcss/typography": "^0.5.9",
    "@types/mdx": "^2.0.6",
    "acorn": "^8.10.0",
    "autoprefixer": "^10.4.15",
    "clsx": "^2.0.0",
    "fast-glob": "^3.3.1",
    "flexsearch": "^0.7.31",
    "framer-motion": "10.15.1",
    "mdast-util-to-string": "^4.0.0",
    "mdx-annotations": "^0.1.3",
    "next": "13.4.13",
    "next-themes": "^0.2.1",
    "react": "18.2.0",
    "react-dom": "18.2.0",
    "react-highlight-words": "^0.20.0",
    "remark": "^14.0.3",
    "remark-gfm": "^3.0.1",
    "remark-mdx": "^2.3.0",
    "shiki": "^0.14.3",
    "simple-functional-loader": "^1.2.1",
    "tailwindcss": "^3.3.3",
    "unist-util-filter": "^5.0.0",
    "unist-util-visit": "^5.0.0",
    "zustand": "^4.4.1"
  },
  "devDependencies": {
    "@types/react": "^18.2.20",
    "eslint": "8.47.0",
    "eslint-config-next": "13.4.13",
    "prettier": "^3.0.1",
    "prettier-plugin-tailwindcss": "^0.5.2"
  }
}
bradlc commented 1 year ago

Hey @AbbasSrour, are you seeing these errors when downloading and running a fresh version of the template? If so please could you share the error message(s), as well as details of your operating system and Node.js version?

AbbasSrour commented 1 year ago

The error log:

> next dev

- ready started server on 0.0.0.0:3000, url: http://localhost:3000
- info automatically enabled Fast Refresh for 1 custom loader
- event compiled client and server successfully in 846 ms (20 modules)
- wait compiling...
- event compiled client and server successfully in 371 ms (20 modules)
- wait compiling /page (client and server)...
- event compiled client and server successfully in 36.3s (1557 modules)
- wait compiling /_error (client and server)...
- error node_modules/.pnpm/@mdx-js+react@2.1.5_react@18.2.0/node_modules/@mdx-js/react/lib/index.js (33:32) @ createContext
- error createContext only works in Client Components. Add the "use client" directive at the top of the file to use it. Read more: https://nextjs.org/docs/messages/context-in-server-component
    at eval (webpack-internal:///(rsc)/./node_modules/.pnpm/@mdx-js+react@2.1.5_react@18.2.0/node_modules/@mdx-js/react/lib/index.js:37:73)
    at (rsc)/./node_modules/.pnpm/@mdx-js+react@2.1.5_react@18.2.0/node_modules/@mdx-js/react/lib/index.js (/home/ares/Downloads/tailwindui-protocol/.next/server/app/page.js:7869:1)
    at __webpack_require__ (/home/ares/Downloads/tailwindui-protocol/.next/server/webpack-runtime.js:33:43)
    at eval (webpack-internal:///(rsc)/./src/app/page.mdx:9:71)
    at (rsc)/./src/app/page.mdx (/home/ares/Downloads/tailwindui-protocol/.next/server/app/page.js:4774:1)
    at Function.__webpack_require__ (/home/ares/Downloads/tailwindui-protocol/.next/server/webpack-runtime.js:33:43)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async collectGenerateParams (/home/ares/Downloads/tailwindui-protocol/node_modules/.pnpm/next@13.4.12_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/build/utils.js:826:17) {
  name: 'TypeError',
  digest: undefined
}
null
- event compiled client and server successfully in 11.7s (1676 modules)
- wait compiling /favicon.ico/route (client and server)...
- event compiled client and server successfully in 3.2s (1744 modules)
- warn Fast Refresh had to perform a full reload due to a runtime error.
- error node_modules/.pnpm/@mdx-js+react@2.1.5_react@18.2.0/node_modules/@mdx-js/react/lib/index.js (33:32) @ createContext
- error createContext only works in Client Components. Add the "use client" directive at the top of the file to use it. Read more: https://nextjs.org/docs/messages/context-in-server-component
    at eval (webpack-internal:///(rsc)/./node_modules/.pnpm/@mdx-js+react@2.1.5_react@18.2.0/node_modules/@mdx-js/react/lib/index.js:37:73)
    at (rsc)/./node_modules/.pnpm/@mdx-js+react@2.1.5_react@18.2.0/node_modules/@mdx-js/react/lib/index.js (/home/ares/Downloads/tailwindui-protocol/.next/server/app/page.js:7869:1)
    at __webpack_require__ (/home/ares/Downloads/tailwindui-protocol/.next/server/webpack-runtime.js:33:43)
    at eval (webpack-internal:///(rsc)/./src/app/page.mdx:9:71)
    at (rsc)/./src/app/page.mdx (/home/ares/Downloads/tailwindui-protocol/.next/server/app/page.js:4774:1)
    at Function.__webpack_require__ (/home/ares/Downloads/tailwindui-protocol/.next/server/webpack-runtime.js:33:43)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async collectGenerateParams (/home/ares/Downloads/tailwindui-protocol/node_modules/.pnpm/next@13.4.12_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/build/utils.js:826:17) {
  name: 'TypeError',
  digest: undefined
}
null``````

The machine I'm using is running Arch, node18.16 through volta-bin, and pnpm for the package manager,

bradlc commented 1 year ago

Thanks for sharing! I can reproduce the issue now. It looks like pnpm might be resolving the dependencies a little differently to npm. Either way I have verified that the issue can be resolved by upgrading the Next.js and MDX dependencies:

pnpm install next@latest eslint-config-next@latest @next/mdx@latest @mdx-js/loader@latest @mdx-js/react@latest

Alternatively you can re-download the template as this has been updated to include the upgraded versions

I hope that helps, but please re-open the issue if you're still experiencing issues 👍