如何强制 npx 使用 yarn 而不是 npm?

how to force npx use yarn instead of npm?

我正在尝试使用 npx 创建 React 应用程序,它曾经自动使用 yarn 但出于某种原因,它现在正在使用 npm...

我通过了 --use-yarn 标志,但没有成功

我的电脑是 运行 Ubuntu 20.04.3 LTS

节点:16.13.2 LTS
npm:8.3.2
纱线:1.22.17

试试这个:

yarn create react-app my-app

我在 Facebook 的 github 回购

#11322 线程中找到了修复

This removes the --use-npm flag and adds the --use-yarn flag. It also removes the previous behavior of checking for the existence of yarn as the signal to use it as the package manager. The new behavior will be to use npm by default and to use yarn with the --use-yarn flag.
The goal of this PR is to remove the check on whether yarn is present in the user's path as the signal to use yarn.
This PR is implemented on top of #11304, since it changed some of the same files and was easier to get tests passing on top of that. I will rework this based on the outcome of that PR. For now, here's the differing commits in this PR: lukekarrys/create-react-app@lk/dev-npm-7...lk/use-npm