ui: [bug]: Cannot read properties of undefined (reading 'resolvedPaths')

Describe the bug

Image

Affected component/components

Almost all components

How to reproduce

Any npx shadcn@latest add causes this issue

Run the npx shadcn@latest add calendar

System Info

Windows 11

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 71
  • Comments: 72

Commits related to this issue

Most upvoted comments

same here! problem solved by using 2.1.8

# ✅ OK
npx shadcn@2.1.8 add dialog

# ❌ NG
npx shadcn@latest add dialog

Installing from the last version, not latest temporarily solves this: npx shadcn@2.1.8 add ...

Awesome. the CLI should handle these cases. I’ll fix.

Anyone coming to this issue, make sure you have aliases defined for components, utils, ui, lib and hooks in your components.json.

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

Ah I see. Looks like you’re missing some aliases. Can you update your aliases in components.json to the following and try again?

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

Same here

I have face the same issue but fixed when i deleted components.json and re Initialize shadcn. just do rm ./components.json

npx shadcn@latest init

I didn’t need to delete my components.json just added the ui path in the aliases and it worked like a charm!

components.json:

  ...
  "aliases": {
    "components": "@/components",
    "utils": "@/lib/utils",
    "ui": "@/components/ui/"  // <<<<< ADDED THIS
  }
}

Ah I see. Looks like you’re missing some aliases. Can you update your aliases in components.json to the following and try again?

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

Works! The error should have indicated at least that the issue was with aliases. Thanks still!

Awesome. the CLI should handle these cases. I’ll fix.

Anyone coming to this issue, make sure you have aliases defined for components, utils, ui, lib and hooks in your components.json.

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

Thanks @shadcn! worked for me too…

Image

Solution : problem solved by using 2.1.8 , Since 29/01/2025

# ✅ Solution
npx shadcn@2.1.8 add select

# ❌ Error
npx shadcn@latest add select

I have face the same issue but fixed when i deleted components.json and re Initialize shadcn. just do rm ./components.json

npx shadcn@latest init

working now for me on Mac.

Missing

"ui": "#app/components/ui",

On

"aliases": {
		"components": "#app/components",
		"utils": "#app/utils/misc.tsx",
		"lib": "#app/lib",
		"hooks": "#app/hooks"
	}

Thank you @shadcn

Awesome. the CLI should handle these cases. I’ll fix. Anyone coming to this issue, make sure you have aliases defined for components, utils, ui, lib and hooks in your components.json.

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

Thank you @shadcn it worked for me and I am on Mac

Thanks for the workaround!

Same here!

It works in my repository composed by Next.js on Mac OS. Thanks!

ex:

npx shadcn@latest add card


working now for me on Mac.

Missing

"ui": "#app/components/ui",

On

"aliases": {
		"components": "#app/components",
		"utils": "#app/utils/misc.tsx",
		"lib": "#app/lib",
		"hooks": "#app/hooks"
	}

Thank you @shadcn

Awesome. the CLI should handle these cases. I’ll fix. Anyone coming to this issue, make sure you have aliases defined for components, utils, ui, lib and hooks in your components.json.

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

Thank you @shadcn it worked for me and I am on Mac

“ui”: “@/components/ui/”

works like a charm

“ui”: “@/components/ui/”

This worked for me as well.

Awesome. the CLI should handle these cases. I’ll fix.

Anyone coming to this issue, make sure you have aliases defined for components, utils, ui, lib and hooks in your components.json.

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

Thank you @shadcn it worked for me and I am on Mac

Ah I see. Looks like you’re missing some aliases. Can you update your aliases in components.json to the following and try again?

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

Thanks @shadcn. Worked for me too.

does anyone get this error now?

⨯ ./src/app/globals.css.webpack[javascript/auto]!=!./node_modules/next/dist/build/webpack/loaders/css-loader/src/index.js??ruleSet[1].rules[13].oneOf[10].use[2]!./node_modules/next/dist/build/webpack/loaders/postcss-loader/src/index.js??ruleSet[1].rules[13].oneOf[10].use[3]!./src/app/globals.css Error: It looks like you're trying to usetailwindcssdirectly as a PostCSS plugin. The PostCSS plugin has moved to a separate package, so to continue using Tailwind CSS with PostCSS you'll need to install@tailwindcss/postcss and update your PostCSS configuration. Import trace for requested module: ./src/app/globals.css.webpack[javascript/auto]!=!./node_modules/next/dist/build/webpack/loaders/css-loader/src/index.js??ruleSet[1].rules[13].oneOf[10].use[2]!./node_modules/next/dist/build/webpack/loaders/postcss-loader/src/index.js??ruleSet[1].rules[13].oneOf[10].use[3]!./src/app/globals.css ./src/app/globals.css

tried above solutions. none worked…

same

# ✅ Solution pnpm dlx shadcn@2.1.8 add label

# ❌ Error pnpm dlx shadcn@latest add label

Same - on mac - vscode