Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compile error after running shadcn-ui init command #746

Closed
chongweiguan opened this issue Jun 27, 2023 · 13 comments
Closed

Compile error after running shadcn-ui init command #746

chongweiguan opened this issue Jun 27, 2023 · 13 comments

Comments

@chongweiguan
Copy link

chongweiguan commented Jun 27, 2023

There seems to be an issue with the shadcn-ui init command.

When creating a new project using npx create-next-app@latest my-app --typescript --tailwind --eslint, and then running npm run dev. No issues so far, the page displayed is shown below.

Screenshot 2023-06-28 at 12 06 08 AM

Next, I ran npx shadcn-ui@latest init and chose the default settings, shown below
Screenshot 2023-06-28 at 12 07 19 AM

However, after running npm run dev again, an error is shown
Screenshot 2023-06-28 at 12 08 08 AM
Screenshot 2023-06-28 at 12 08 21 AM

I really enjoy using shadcn and I hope this can be fixed soon! This seems to be a similar issue faced by #745. Do let me know if you need me to provide other information for you

@dan5py
Copy link
Contributor

dan5py commented Jun 27, 2023

@chongweiguan Are you using the src folder?

@chongweiguan
Copy link
Author

Hi! if you are asking if the src folder is my working directory when running npm run dev then yes I am

@dan5py
Copy link
Contributor

dan5py commented Jun 27, 2023

Then you must say it in this prompt (init):

- Where is your global CSS file? › app/globals.css
+ Where is your global CSS file? › src/app/globals.css

Otherwise a new app folder is created, causing the not found error.

@dan5py
Copy link
Contributor

dan5py commented Jun 27, 2023

If you already have the components.json file you can just edit the tailwind.css property in it and delete the wrong app folder.

- "css": "app/globals.css",
+ "css": "src/app/globals.css",

@chongweiguan
Copy link
Author

Oh ok it is working now! Thank you very much for the help!

@macgeargear
Copy link

can i see your components.json @chongweiguan

@chongweiguan
Copy link
Author

@macgeargear
Screenshot 2023-06-28 at 12 40 28 AM

@EugenePeter
Copy link

The you must say it this prompt (init):

- Where is your global CSS file? › app/globals.css
+ Where is your global CSS file? › src/app/globals.css

Otherwise a new app folder is created, causing the not found error.

I have the same issue however my project is a pre existing project with lots of code in the app folder. How to resolve it without deleting app folder?

@dan5py
Copy link
Contributor

dan5py commented Jun 28, 2023

@EugenePeter You don't have to delete the original app folder, just the one that the CLI created.

@dan5py
Copy link
Contributor

dan5py commented Jun 28, 2023

Then you have to edit the path of the css in the components.json file:

- "css": "app/globals.css",
+ "css": "src/app/globals.css",

(Assuming that you're using the src folder)

@EugenePeter
Copy link

It's working as expected now . Cheers @dan5py

@samadaman
Copy link

Still Not Working...& Showing 404 on browser.

@schmanat
Copy link

schmanat commented Oct 3, 2023

Still Not Working...& Showing 404 on browser.

After updating the components.json file the error still exists. My solution was that I have to the delete the app/globals.css folder. In my project structure exists the globals.css twice.

app/globals.css
src/app/globals.css

After deleting the app/globals.css the app works as expected again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants