#Unable to run binary executable when `package.json` script name is the same

1 messages · Page 1 of 1 (latest)

supple junco
#

Hi,

Storybook Core maintainer here!

At Storybook we are supporting several package managers and I want to optimize support for our bun users.

Sometimes we want to run the locally installed storybook binary to run certain scripts. Running bun storybook automigrate ... doesn't work, if there is a equally named script storybook present in the package.json. Running bun run storybook automigrate ... has the same result. Other package managers have implemented different behaviour when calling e.g. pnpm storybook (calling the package.json script) vs pnpm exec storybook (which will call the storybook binary). For me it seems like I don't have any possibility in bun to call the storybook binary if a script entry named storybook exists in the user's package.json.

past jasper
supple junco
#

Doesn't bunx storybook always download the latest package from the registry, or does it favour the local one?

past jasper
#

it reads node_modules/.bin as a higher piority

#

iirc it finds something like this

  • node_modules/.bin/*
  • in path
  • finally actually get package
supple junco
#

Thank you. That's great to know!

past jasper
#

np

#

yeah its a little different to npx, but imo its better lol

#

you can slap a @latest and it will force get it properly from npm tho

supple junco
#

yarn dlx and pnpm dlx behave differently AFAIK. They always fetch the latest package and run the package in a temporary environment and they never prefer the local package. I know, nothing you have to know, but eventually you can verify this assumption.

past jasper
#

wait i thought pnpm dlx was the same as pnpx 😭

supple junco
#

It is, isn't it? It is an alias for pnpm dlx

past jasper
#

so they are the same thing, cool

#

also if you didn't already know bun x ... is also a legit thing

#

(can be helpful if you have direct path to bun or smth)

supple junco
#

Thanks!

past jasper
#

feel free to ping me if you have any other Q's :)