javascriptnpmyarnpkg

yarn dlx not found. Why?! How to run yarn dlx command?


I installed yarn by

brew install yarn  

i try

yarn dlx storybook@latest upgrade

result:

yarn run v1.22.22
error Command "dlx" not found.
info Visit https://yarnpkg.com/en

yarn add or yarn install working correctly


Solution

  • You need to uninstall yarn again using brew and/or npm, depending on how you installed it. Then just enable corepack and you'll have access to the latest version of yarn. So run corepack enable and you should be good to go.

    If you need a specific global version of yarn you can then run corepack install --global yarn@x.y.z or corepack install --global yarn@latest etc.

    Depending on your node version, and how you installed node, you might have to upgrade and/or install it manually by running npm install -g corepack. But if you have a fairly recent install of Node, and your package manager isn't doing anything weird, you should be good 🙂

    Node has more info here: https://nodejs.org/api/corepack.html And Yarn has more information here: https://yarnpkg.com/corepack