reactjsviteshadcnui

Shadcn: No import alias found in your tsconfig.json file


I'm following the Shadcn docs to set up vite react app project, but when I run the following command:

npx shadcn@latest init

I get the error:

No import alias found in your tsconfig.json file. Visit https://ui.shadcn.com/docs/installation/vite to learn how to set an import alias.

I've set up my tsconfig.json file according to the Shadcn setup docs, so I'm not sure what's going wrong. How do I fix this error?


Solution

  • I found a fix in a corresponding Github issue. You just have to add ./ in front of src in your tsconfig.json file, like so:

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