V0 includes @/components as a dependency which is invalid

I have made a component with v0 and i can’t install it with the shadcn CLI. the problem is that the JSON result includes “@/components” as a dependency and because of that I am getting the following error:

Something went wrong. Please check the error below for more details.
If the problem persists, please open an issue on GitHub.

Command failed with exit code 4294963238: npm install @/components @radix-ui/react-slot
npm ERR! code ENOENT
npm ERR! syscall open
npm ERR! path @\components/package.json
npm ERR! errno -4058
npm ERR! enoent ENOENT: no such file or directory, open ‘@\components\package.json’
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent

npm ERR! A complete log of this run can be found in: C:\Users\user\AppData\Local\npm-cache_logs\2024-09-03T14_51_58_953Z-debug-0.log

screenshot

Hi, and welcome @orifrifoxs-gmailcom!

It seems that the error you’re encountering with the shadcn CLI is due to the component using @/components as an import path, which is a Next.js-specific alias that the CLI interprets as a non-existent npm package.

To resolve this, you need to modify the component file by replacing all imports from @/components/ui with their corresponding @shadcn/ui imports.

For example, change import { Button } from "@/components/ui/button" to import { Button } from "@shadcn/ui/button".

After making these adjustments to all shadcn/ui component imports, you should be able to successfully install the component using the shadcn CLI without the “@/components” error.

Let us know how you get on!

2 Likes

the shadcn cli tries to install @/components because it’s a dependency in the v0 JSON output but npm can’t install that because that’s invalid

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.