-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
[bug]: Module not found: Error: Can't resolve '@/components/ui ....... #3705
Comments
|
Hi you can resolve it just by replacing your path is here ---> "@/": ["./"], , replace with this "@/": ["./src/"], in your tsconfig.ts file |
But the components folder is not inside of the src folder |
And I already tried setting a definite path in the config to the folder. It did not work on reactscripts start. |
um when you install can you write the step how you install the component |
Just with the normal component install. It installs it directly to components/ui at root |
hello, very interesting that this happend to Quitscher two hours ago, since this same issue arrived for me out of nowhere 2 hours ago aswell, and im trying to fix it. |
hello i fixed it by deleting a tsconfig file but that also isn't optimal |
npx shadcn-ui@latest add --all |
and you are updated config file or not ..? |
Ofcourse but it is still correct |
noo... please read beforehand. |
You can Please Share a screenshot |
and your file structure screenshot |
try this ==> @/app/components/ui/button |
it is just a runtime error when doing "start": "react-scripts start", |
it is not inside of /app/ |
It does not matter (at least it should not) what the file structure is, when my imports are correct. As I stated earlier, it seems to be a problem with react-scripts! This topic needs some experts in that direction. |
I encountered similar issue.
and defined aliases in
this placed shadcn components at the
and adjusted
this placed shadcn components inside |
I followed this manual (https://ui.shadcn.com/docs/installation/vite) and it's working fine. However, it's not working with a project bootstrapped with create-react-app, but it's working fine with Vite installation. |
Thats the point. I just want the create-react-app. No Vite or Next.js. |
I had the same problem, and I spent the whole night messing around with it. I finally found the solution. Reference : https://stackoverflow.com/questions/50679031/why-are-these-tsconfig-paths-not-working Just add one line of code in tsconfig.app.json as follows:
So the whole code looks like this:
Hope this helps those of you who have the same problem. |
This seems like a project bootstrapped with Vite, not Create React App. |
Shadcn-ui uses import aliases, which create-react-app doesn't support yet. Here is the related issue: facebook/create-react-app#12047. |
That's right, my project bootstrapped with Vite. @SureshPradhana
It's unfortunate that create-react-app has problems handling aliases. I tried it earlier and ended up the same as @Quietscher I saw that someone can make shadcn/ui work well with create-react-app and he has also provided a starter template: https://github.com/ahmad1702/shadcn-ui-cra |
@alfinauzikri I've created the project and followed the exact instructions as per : https://ui.shadcn.com/docs/installation/vite. Sorry if I'm repeating in this case something that other's experienced, but in the shadcn installation docs, the resolve alias is set to ./src and the installation of shadcn goes in the root project, not in the src/folder . |
Set the aliases in components.json as follows:
Delete the @ folder and then run
|
@alfinauzikri the template repo doesn't work solely with Create React App; it uses CRACO. Personally, I don't like using it because it isn't good for updates with Create React App. However, we can use it as a workaround |
That's right, he has modified it. |
Okay, thank you @vasvalstan for providing all the screenshots and I have seen them, change it to something like this. Simply set the paths or aliases in this file. tsconfig.json
Then extends in tsconfig.app.json
Restore the content of the tsconfig.node.json file to the original. For the vite.config.ts and components.json file, there is no problem. Delete the @ folder and then run |
Thank you @alfinauzikri, saved me hours. Now it all makes sense putting the compiler options in the tsconfig file and extend it in the .app. Thank you again, hope it helps others as well. |
You're welcome. Glad to hear that the problem has been resolved.. :) |
Thanks @alfinauzikri it actually worked!!! |
This worked for me too, thanks |
Thanks @alfinauzikri My issue is resolved. |
this solved it for me at least using vite, just changing the path in components and reinstalling |
is it fixed for create-react-app yet? |
Hi |
I've been using
I've fixed the " Here's how:
If you're using React TypeScript, make sure the '@'-alias is also present in your
Note: Inside
|
It has helped me |
Describe the bug
When using create react app and compiling / starting the react-scripts start command, you get
Module not found: Error: Can't resolve '@/components/ui .......
Also found here:
#1101 (comment)
Affected component/components
all
How to reproduce
create a react app by create react app (i added typescript)
add shadcn
create a component
run start script
Codesandbox/StackBlitz link
No response
Logs
No response
System Info
Before submitting
The text was updated successfully, but these errors were encountered: