shadcn-ui / ui

Beautifully designed components that you can copy and paste into your apps. Accessible. Customizable. Open Source.
https://ui.shadcn.com
MIT License
62.84k stars 3.53k forks source link

Bug(CLI): 404 This page could not be found - NextJS #2302

Closed lem0n4id closed 4 months ago

lem0n4id commented 5 months ago

This is a copy of the issue #1821, reproduced the bug

When i initialize shadcn/ui using npx shadcn-ui@latest init, the nextjs app gives 404 page on all routes (including '/').

This bug is likely to be caused because globals.css is being created in the root of the project as reported in the thread of the original issue.

I have reproduced this bug(#1821) in lem0n4id/shadcnui-cli-bug.

Clone the repo and run OR you can open it in Gitpod too from the button below.

Open in Gitpod

Proposed Changes

Update the CLI default for "Where is your global CSS file?" to src/app/globals.css from app/globals.css

Steps to reproduce

  1. run npx create-next-app@latest shadcnui-cli-bug --typescript --tailwind --eslint and press enter to choose all the defaults. ✔ Would you like to use src/ directory? … No / Yes ✔ Would you like to use App Router? (recommended) … No / Yes ✔ Would you like to customize the default import alias (@/*)? … No / Yes

  2. cd into your project. cd shadcnui-cli-bug/

  3. run npx shadcn-ui@latest init and press enter to choose all the defaults. ✔ Would you like to use TypeScript (recommended)? … no / yes ✔ Which style would you like to use? › Default ✔ Which color would you like to use as base color? › Slate ✔ Where is your global CSS file? … app/globals.css ✔ Would you like to use CSS variables for colors? … no / yes ✔ Are you using a custom tailwind prefix eg. tw-? (Leave blank if not) … ✔ Where is your tailwind.config.js located? … tailwind.config.js ✔ Configure the import alias for components: … @/components ✔ Configure the import alias for utils: … @/lib/utils ✔ Are you using React Server Components? … no / yes ✔ Write configuration to components.json. Proceed? … yes

  4. run npm run dev

    shadcnui-cli-bug@0.1.0 dev next dev

    ▲ Next.js 14.0.4

    ✓ Ready in 2.6s ○ Compiling /not-found ... ✓ Compiled /not-found in 2.9s (395 modules)

Output

Screenshot of 404 page

shadcn commented 4 months ago

This issue has been automatically closed because it received no activity for a while. If you think it was closed by accident, please leave a comment. Thank you.