ui icon indicating copy to clipboard operation
ui copied to clipboard

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

Open lem0n4id opened this issue 1 year ago • 0 comments

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

[email protected] dev next dev

▲ Next.js 14.0.4

  • Local: http://localhost:3000

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

Output

Screenshot of 404 page

lem0n4id avatar Jan 06 '24 08:01 lem0n4id