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

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

Open
2 tasks done
hieu23143242 opened this issue Oct 13, 2024 · 2 comments
Open
2 tasks done
Labels
bug Something isn't working

Comments

@hieu23143242
Copy link

hieu23143242 commented Oct 13, 2024

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 [email protected] init

shadcn@latest add button

npm start

Codesandbox/StackBlitz link

No response

Logs

No response

System Info

Create React App

Before submitting

  • I've made research efforts and searched the documentation
  • I've searched for existing issues
@hieu23143242 hieu23143242 added the bug Something isn't working label Oct 13, 2024
@hieu23143242
Copy link
Author

file structure:

godagodga

@Boby900
Copy link

Boby900 commented Oct 18, 2024

you can try out this, if it will work,

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

@hieu23143242

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants