运行 npm install -g yarn 不起作用


¥Running npm install -g yarn doesn't work

npm 防止在进行全局安装时意外覆盖 Corepack 二进制文件。为避免此问题,请考虑以下选项之一:

¥npm prevents accidentally overriding the Corepack binaries when doing a global install. To avoid this problem, consider one of the following options:

  • 不要运行这个命令;Corepack 无论如何都会提供包管理器二进制文件,并确保请求的版本始终可用,因此不需要显式安装包管理器。

    ¥Don't run this command; Corepack will provide the package manager binaries anyway and will ensure that the requested versions are always available, so installing the package managers explicitly isn't needed.

  • npm install 加上 --force 标志;这将告诉 npm 可以覆盖二进制文件,但你将在此过程中删除 Corepack 文件。(运行 corepack enable 将它们添加回来。)

    ¥Add the --force flag to npm install; this will tell npm that it's fine to override binaries, but you'll erase the Corepack ones in the process. (Run corepack enable to add them back.)