ui icon indicating copy to clipboard operation
ui copied to clipboard

Add an option in CLI to choose package managers (such as npm, yarn, pnpm) for installing dependencies

Open ryadav96 opened this issue 2 years ago • 5 comments
trafficstars

ryadav96 avatar Apr 18 '23 09:04 ryadav96

This should be automatic. The CLI will detect which package manager the project is using and use that. Let me know if this is not working.

shadcn avatar Apr 18 '23 15:04 shadcn

I'm using yarn for my project and when I use npx shadcn-ui init and npx shadcn-ui add button, it creates a package-lock.json. image

makyinmars avatar Apr 19 '23 01:04 makyinmars

@shadcn Its not working. I am using pnpm

ryadav96 avatar Apr 19 '23 10:04 ryadav96

@ryadav96 pnpx shadcn-ui add button?

shadcn avatar Apr 19 '23 10:04 shadcn

I think you have to use:

  • npx for npm
  • yarn dlx for yarn
  • pnpx or pnpm dlx for pnpm

in order to solve this. The package manager is inherited by the shell not by current files :)

rawnly avatar Apr 22 '23 19:04 rawnly

Thank you, @shadcn, this command worked: pnpx shadcn-ui add button.

ryadav96 avatar Apr 24 '23 07:04 ryadav96

I'm not being able to install it. Tried it first with pnpm, not working, getting code error 1 from a package called three sitters. Also the code it copies from pnpm on your docs is with pnpx which does not work anymore on pnpm, you should change it to pnpm dlx. Getting all the same errors with normal npm, and can't run the equivalent npx command for yarn which would be yarn create or yarn dlx

migsdeving avatar Apr 30 '23 22:04 migsdeving

@migsdeving Yes, using pnpm should be with pnpm dlx. Source: https://pnpm.io/cli/dlx

mhaidarhanif avatar Apr 30 '23 23:04 mhaidarhanif

I used " pnpm dlx shadcn-ui@latest init" - copied directly from the documentation and got the following error: " ERROR  Command failed with exit code 1: shadcn-ui init". I tried using "pnpx shadcn-ui@latest init" as well and I got the same error " ERROR  Command failed with exit code 1: shadcn-ui init". npm gives me proxy errors when installing react.js and next.js so I switched to pnpm, which is giving me the above errors.

Hanney-Ali avatar Jul 30 '23 09:07 Hanney-Ali

I've tried both pnpm dlx and pnpx: pnpm dlx shadcn-ui@latest add "dropdown-menu"

And with both I'm getting the same error. It seems shadcn is trying to use npm:

 Installing dropdown-menu...Command failed with exit code 1: npm install @radix-ui/react-dropdown-menu

vincaslt avatar Nov 21 '23 09:11 vincaslt

I had the similar error while using pnpm. Turns out I had a setting in my package.json that states:

"packageManager": "[email protected]"

Removing it fixed the issue

oddiz avatar Dec 12 '23 17:12 oddiz

Thanks @oddiz that worked to fix my issue as well.

andrewmartin avatar Mar 15 '24 03:03 andrewmartin