ui: Error with installing packages trough the CLI with Bun

I noticed a strange problem when using the CLI to add components or to initialize a project. It fails to install the new dependencies and gives an error that looks like this:

Command failed with exit code 1: npm install [DEPENDENCY NAME]
npm ERR! fh.read is not a function. (In 'fh.read(buf, 0, 2048, 0)', 'fh.read' is undefined)

Or:

Invalid stdio option "undefined"

Commands with this issue:

bunx --bun shadcn-ui@latest init
bunx --bun shadcn-ui@latest add [ANY COMPONENT THAT ADDS NEW DEPENDENCIES]

It adds the component files normally, so it’s not completely unusable, but you just have to install the new dependencies manually.

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 3
  • Comments: 15

Most upvoted comments

This issue hasn’t been fix. I don’t see the point of closing it.

I’m working on other things right now, but have you guys done a bun upgrade recently?

I was having the same issue but after bun upgrade from v1.0.22 to v1.0.30 everything seems to be good now!

image

stop your running termianl or any development terminal and then install shadcn ui components. It will fix the error

I’m actually getting this error when I try to init shadcn:

$ bunx --bun shadcn-ui@latest init

✔ Which style would you like to use? › Default
✔ Which color would you like to use as base color? › Zinc
✔ Would you like to use CSS variables for colors? … no / yes

✔ Writing components.json...
✔ Initializing project...
⠋ Installing dependencies...Command failed: bun add tailwindcss-animate class-variance-authority clsx tailwind-merge lucide-react
Invalid stdio option "undefined"

Hello sir, I’m facing the same problem, Can you help me fix it?

Upgrade Bun with bun upgrade to fix that issue