ui: [bug]:Error: Cannot read properties of undefined (reading 'resolvedPaths')
Describe the bug
I’m encountering an error when trying to install the pagination component from ShadCN into my Next.js project. The error message is: Cannot read properties of undefined (reading ‘resolvedPaths’). This issue occurs when I attempt to integrate the pagination component, preventing the installation from completing successfully.
Steps to Reproduce: To reproduce the issue, I created a new Next.js project (or opened an existing one), and then tried installing the ShadCN pagination component. When running the installation command, the error message appeared.
Expected Behavior: The pagination component should install without any issues and be functional in the Next.js project.
Actual Behavior: The installation fails with the error message: Cannot read properties of undefined (reading ‘resolvedPaths’).
Affected component/components
Page
How to reproduce
To reproduce the issue, I created a new Next.js project (or opened an existing one), and then tried installing the ShadCN pagination component. When running the installation command, the error message appeared.
Codesandbox/StackBlitz link
No response
Logs
The error message is: Cannot read properties of undefined (reading 'resolvedPaths').
System Info
Terminal
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: 64
- Comments: 22
Hello, try the following, I believe it will work.
Delete your
components.jsonfile. Runnpx shadcn@latest init. Then try adding a component as a test.Try doing this in a copy of your project. This worked for me.
Solution: https://github.com/shadcn-ui/ui/issues/6527#issue-2823569500
Got this same error when installing the toast.
Shadcn himself says this is the fix https://github.com/shadcn-ui/ui/issues/6527#issue-2823569500
You need to have aliases defined for these 5 things in the components.json file. Nuking it and installing again adds, these, but you don’t have to you can just add them.
“aliases”: { “components”: “@/components”, “utils”: “@/lib/utils”, “ui”: “@/components/ui”, “lib”: “@/lib”, “hooks”: “@/hooks” }
✅ OK
npx shadcn@2.1.8 add dialog
❌ NG
npx shadcn@latest add dialog
Me too, I got the same error when adding the slider component from Shadcn CLI and fixed it as mentioned in the following solution, thanks!
I believe the above will work in most cases but if not, try these steps:
This solution 100% works! https://github.com/shadcn-ui/ui/issues/6527#issue-2823569500
This solution should be the correct answer
This worked for me. THX @jhonypdev
The Solution of giving a
npx shadcn@latest initupdates the code, but be careful if you have styling variables, try just giving the command and copying your variables and putting them again, otherwise it will reset everything!Same issue - just FYI for the team:
When trying to add dropdown using
npm