ui icon indicating copy to clipboard operation
ui copied to clipboard

404 This page could not be found, on Any Route in NextJS

Open yhoungdev opened this issue 9 months ago • 21 comments

My Application was working fine. but after initializing ShadCN with pnpm dlx shadcn-ui@latest init inito my next, i can no longer get any route again.

I started getting 404 page Screenshot from 2023-10-24 04-57-36

yhoungdev avatar Oct 24 '23 03:10 yhoungdev

Can you share your components.json file please? A dir structure (overview) of your Next.js project would help as well.

shadcn avatar Oct 24 '23 12:10 shadcn

I had the same problem. Somehow there were two app folders. One on the root level and one in src. In both of them, there was global.css. Maybe I did something wrong when initializing the project. I moved the global.css from the outer to the inner app folder, deleted the outer and the problem was solved.

stefandim91 avatar Oct 25 '23 15:10 stefandim91

I had the same problem. Somehow there were two app folders. One on the root level and one in src. In both of them, there was global.css. Maybe I did something wrong when initializing the project. I moved the global.css from the outer to the inner app folder, deleted the outer and the problem was solved.

I ran into this same issue. thanks for sharing your fix!

timconnorz avatar Oct 26 '23 02:10 timconnorz

I had the same problem. Somehow there were two app folders. One on the root level and one in src. In both of them, there was global.css. Maybe I did something wrong when initializing the project. I moved the global.css from the outer to the inner app folder, deleted the outer and the problem was solved.

No you didn't do anything wrong.

This was the reason why you might be facing that.

  • You create a new nextJs application
  • And after that you wanna init shadCN UI With pnpm dlx shadcn-ui@latest init this process makes it look like it is initialising another project.

Because sometimes it can create a tailwind.config.js and tailwind.config.ts

yhoungdev avatar Oct 26 '23 20:10 yhoungdev

This happened to me too. For reference, I have a src folder that houses app and am thinking maybe the shadcn CLI didn't account for it... but only for the globals weirdly?

devdumpling avatar Oct 29 '23 12:10 devdumpling

This happened to me too. For reference, I have a src folder that houses app and am thinking maybe the shadcn CLI didn't account for it... but only for the globals weirdly?

by Default when setting NextJs, it asks if you want to use SRC dir / if yes then it will create an SRC folder that is gonna house the App folder

yhoungdev avatar Oct 29 '23 13:10 yhoungdev

@devdumpling the cli should handle src dir. Any chance you can post an overview of your project structure so that I can take a look?

shadcn avatar Oct 30 '23 17:10 shadcn

@devdumpling the cli should handle src dir. Any chance you can post an overview of your project structure so that I can take a look?

YEa @devdumpling you should post an overview

yhoungdev avatar Oct 30 '23 18:10 yhoungdev

I just hit the same problem: it didn't detect an existing src folder during setup and i didn't change path to css so it created a new folder.

ex3ndr avatar Nov 10 '23 19:11 ex3ndr

How where you able to resolve it.

And @shadcn has this issue been resolved?🙏

yhoungdev avatar Nov 10 '23 19:11 yhoungdev

I have merged generated file to the right place and updated components.json

ex3ndr avatar Nov 10 '23 20:11 ex3ndr

where do things go specifically here? I've also hit this issue.

@shadcn it happens on the path of the installation instructions - if you're using pnpm and follow instructions directly and just hit enter through everything you get this issue:

https://ui.shadcn.com/docs/installation/next

nicolaerusan avatar Nov 12 '23 16:11 nicolaerusan

Awesome

yhoungdev avatar Nov 12 '23 16:11 yhoungdev

@nicolaerusan Thanks for the updates. I'll mark this as a bug and look into it.

shadcn avatar Nov 12 '23 18:11 shadcn

Let me know if there's anything I can do to help debug & thanks @shadcn!

Any workaround suggestions for installing?

I tried to move the files around to the appropriate spots but the tailwind based styling was still broken so must not have adjusted all the pieces needed

nicolaerusan avatar Nov 12 '23 20:11 nicolaerusan

The problem happens because globals.css is being created in the root of the project.

Delete the app folder in the root and restart the development server and it will work.

image

luanfvieira avatar Nov 24 '23 17:11 luanfvieira

I noticed that during my original installation that I had the same issue, and then was easily able to fix once i was moved globals.css

Obsidian-AI avatar Nov 28 '23 05:11 Obsidian-AI

Not intuitive but if your globals.css is at src/app/globals.css you should include the src when answering the following prompt or a duplicate app directory and globals.css is created.

Screenshot 2023-12-26 at 10 15 30 PM

hou-man avatar Dec 27 '23 06:12 hou-man

Not intuitive but if your globals.css is at src/app/globals.css you should include the src when answering the following prompt or a duplicate app directory and globals.css is created.

Screenshot 2023-12-26 at 10 15 30 PM

This works! Maybe updating the cli default to src/app/globals.css will fix this issue!

lem0n4id avatar Jan 06 '24 07:01 lem0n4id

Has this issue been fixed on the Cli ?

If yes the issue can be closed or moved to discussion

yhoungdev avatar Jan 06 '24 19:01 yhoungdev

Has this issue been fixed on the Cli ?

If yes the issue can be closed or moved to discussion

Not yet. I am in process of submitting a PR fixing this

lem0n4id avatar Jan 06 '24 20:01 lem0n4id

This issue has already been fixed

yhoungdev avatar Feb 23 '24 09:02 yhoungdev

The team did a really great work 🤩

yhoungdev avatar Feb 23 '24 09:02 yhoungdev