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
75.12k stars 4.69k forks source link

[bug]: Module not found: Error: Can't resolve '@/components/ui/button'... #5356

Open hieu26122004 opened 1 month ago

hieu26122004 commented 1 month ago

Describe the bug

I am using create react app and encountering the above error: Module not found: Error: Can't resolve '@/lib/utils' The above doesn't happen if I write the following "../../lib/utils"

// tsconfig.json { "compilerOptions": { "target": "ES2020", "useDefineForClassFields": true, "lib": ["ES2020", "DOM", "DOM.Iterable"], "module": "ESNext", "skipLibCheck": true, "baseUrl": ".", "paths": { "@/": ["./src/"] }, "moduleResolution": "bundler", "allowImportingTsExtensions": true, "resolveJsonModule": true, "isolatedModules": true, "noEmit": true, "jsx": "react-jsx", "strict": true, "noUnusedLocals": true, "noUnusedParameters": true, "noFallthroughCasesInSwitch": true }, "include": ["src"] }

//components.jsons { "$schema": "https://ui.shadcn.com/schema.json", "style": "new-york", "rsc": true, "tsx": true, "tailwind": { "config": "tailwind.config.js", "css": "src/index.css", "baseColor": "slate", "cssVariables": true, "prefix": "" }, "aliases": { "components": "@/components", "utils": "@/lib/utils" } }

Affected component/components

Button,...

How to reproduce

npx shadcn-ui@0.8.0 init

shadcn@latest add button

npm start

Codesandbox/StackBlitz link

No response

Logs

No response

System Info

Create React App

Before submitting

hieu26122004 commented 1 month ago

file structure:

godagodga

Boby900 commented 1 month ago

you can try out this, if it will work,

{
  "compilerOptions": {
    "baseUrl": "src",
    "paths": {
      "@/": ["./src/"]
    }
  }
}

@hieu23143242