最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - yarn dlx not found. Why?! How to run yarn dlx command? - Stack Overflow

programmeradmin3浏览0评论

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 

yarn add or yarn install working correctly

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

Share Improve this question asked Mar 14, 2024 at 16:14 GelloissGelloiss 1941 gold badge3 silver badges10 bronze badges 5
  • You installed version 1.x which doesn't have this command yarnpkg.com/getting-started/install – Konrad Commented Mar 14, 2024 at 16:20
  • But I just installed yarn! I installed it with both npm and brew. So I must have an up-to-date yarn package if I just installed it. Thanks for the link, I'll give it a try. – Gelloiss Commented Mar 14, 2024 at 16:23
  • No, it's not possible to install yarn version higher than 1.x from npm or brew – Konrad Commented Mar 14, 2024 at 16:28
  • What's the point? Isn't that the most popular way to install yarn? Why are they giving away obviously outdated software? @Konrad – Gelloiss Commented Mar 14, 2024 at 16:31
  • "Modern releases of Yarn aren't meant to be installed globally, or from npm." - this is what they say, but I don't know why. They changed it with 2.x – Konrad Commented Mar 14, 2024 at 16:34
Add a comment  | 

4 Answers 4

Reset to default 5

Since the point of yarn dlx is to install a package within a temporary environment and no lock file or residuals artifacts are left behind, I just used npx which does the same thing as dlx and doesn't conflict.

No need to uninstall anything, just make sure you have the latest version of Yarn. For example, if you installed it with npm, first update Yarn, then set it to version 2, which is the Berry version, and that's it.

npm install -g yarn
yarn set version berry

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 [email protected] 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

发布评论

评论列表(0)

  1. 暂无评论