Geekyvinayak
Geekyvinayak

Reputation: 342

Shadcn error module not found: Error: Can't resolve '@/components/ui/accordion' in 'Desktop/sadcn/src'

i am using shadcn with simple react app with typescript installed but i'm getting this error

module not found: Error: Can't resolve '@/components/ui/accordion' in '/home/vinayak/Desktop/sadcn/src'

i have installed it using shadcn cli and kept typescript component option as no so i get jsx components only every time.

here is my tsconfig file ::

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

Here is my project tree

- .gitignore
- README.md
- app
  - globals.css
- components
  - ui
    - accordion.jsx
- components.json
- lib
  - utils.js
- package-lock.json
- package.json
- public
  - favicon.ico
  - index.html
  - logo192.png
  - logo512.png
  - manifest.json
  - robots.txt
- src
  - App.css
  - App.js
  - App.test.js
  - index.css
  - index.js
  - logo.svg
  - reportWebVitals.js
  - setupTests.js
- tailwind.config.js
- tsconfig.json

How to fir it ??

Upvotes: 1

Views: 1725

Answers (2)

Nicolaskn
Nicolaskn

Reputation: 584

I add similar issue, because I skipped the initial parts of the documentation.

Since Shadcn is a collection of components and not a component library. You need to add each component that you plan to use in your project.

In your case, since you want to use the accordion component. You need to run the command:

npx shadcn@latest add accordion

Upvotes: 0

Tebogo sizwe Mohale
Tebogo sizwe Mohale

Reputation: 1

I resolved this issue. Put this on your terminal :

  • npm install shadcn-ui@latest
  • npm install npx shadcn-ui@latest init

Upvotes: 0

Related Questions