ui: [bug]: Components installed to wrong directory Remix

Describe the bug

Components not being installed to location defined in component.json. Instead a components folder in the root directory is being created.

components.json

  "aliases": {
    "components": "~/components",
    "utils": "~/lib/utils",
    "ui": "~/components/ui",
    "lib": "~/lib",
    "hooks": "~/hooks"
  }

tsconfig.json

    "baseUrl": ".",
    "paths": {
      "~/*": ["./app/*"]
    },

Affected component/components

All

How to reproduce

Followed steps described here https://ui.shadcn.com/docs/installation/remix

Codesandbox/StackBlitz link

https://stackblitz.com/edit/remix-run-remix-c99tma?file=tailwind.config.ts

Logs

No response

System Info

ProductName:		macOS
ProductVersion:		14.6.1
BuildVersion:		23G9

Before submitting

  • I’ve made research efforts and searched the documentation
  • I’ve searched for existing issues

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 27
  • Comments: 25

Most upvoted comments

Facing the same issue in Laravel, it should be installed in ./resouces/js/components/ui but instead it’s installing in ./components/ui/.

tsconfig.json

{
    "compilerOptions": {
        "allowJs": true,
        "module": "ESNext",
        "moduleResolution": "bundler",
        "jsx": "react-jsx",
        "strict": true,
        "isolatedModules": true,
        "target": "ESNext",
        "esModuleInterop": true,
        "forceConsistentCasingInFileNames": true,
        "skipLibCheck": true,
        "noEmit": true,
        "baseUrl": ".",
        "paths": {
            "@/*": ["./resources/js/*"],
            "@images/*": ["./resources/images/*"],
            "ziggy-js": ["./vendor/tightenco/ziggy"]
        }
    },
    "include": ["resources/js/**/*.ts", "resources/js/**/*.tsx", "resources/js/**/*.d.ts"]
}

components.json

{
  "$schema": "https://ui.shadcn.com/schema.json",
  "style": "new-york",
  "rsc": false,
  "tsx": true,
  "tailwind": {
    "config": "tailwind.config.js",
    "css": "resources/css/app.css",
    "baseColor": "neutral",
    "cssVariables": true,
    "prefix": ""
  },
  "aliases": {
    "components": "@/components",
    "utils": "@/lib/utils",
    "ui": "@/components/ui",
    "lib": "@/lib",
    "hooks": "@/hooks"
  }
}

having the same issue with remix

having same issue with laravel ,I’ve tried making a new project, but the new init still doesn’t work, I think this is related to the sidebar update? Yesterday it was still okay

The same issue for me when adding components. It should be added inside app folder instead components added in root folder

I pushed a fix for it. Can we confirm if it’s working now? (also let’s track in #5433)

Wasted an hour on this thinking it was a user error lol, AdonisJS + Intertia + React + ShadCN/UI. Actually, exactly the same setup as https://github.com/johnpgr/adonisjs-inertia-react-shadcnui which I just found. Previously it worked, new CLI now isn’t working. Was about to shoot my PC haha

Yes, I’m facing the same issue. It was working well 1 week ago, I didin’t change anything. [Remix]

I pushed a fix for it. Can we confirm if it’s working now? (also let’s track in #5433)

Can confirm components are being installed to the correct directory (as specified in components.json and tsconfig /app/components/) in Remix

Thanks a million!

@shmuli9 You can do this in your components.json file:


"aliases": {

  "components": "@/shadcn",

  "ui": "@/shadcn/ui",

}

This will put all components in ./shadcn and ui in ./shadcn/ui

Oh, you mean after init, modify the components.json? That occurred to me, but wasn’t sure why the old behaviour wasn’t working

I think there is still an issue because init doesn’t accept the “@/*” path as a valid alias.

But for now your suggestion should be a good enough workaround for me. Thanks @shadcn

This is working partly, but still not behaving as I would expect.

When I set my tsconfig like so:

    "paths": {
      "~/*": ["./app/*"]
    },

shadcn installs “correctly” to app/["lib"/"components"/"hooks"], but I am trying to set a custom directory for shadcn components like so:

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

this fails with the following error:

npx shadcn@latest init
✔ Preflight checks.
✔ Verifying framework. Found Vite.
✔ Validating Tailwind CSS.
✖ Validating import alias.

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.

In previous CLI you could set a custom import alias, but for some reason in v2 this doesnt work as expected. It seems like only ~/ is supported as a custom import

Urgh, this sucked up 2 hours of my life… Same issue and cant seem to find a fix

Using shadcn-ui@0.8.0 works as expected though

(in my case I have aliases for my main app: "~/*": ["./app/*"], and "@/*": ["./app/shadcn/*"])