运行 npm install -g yarn 不起作用


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

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

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

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

  • 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.

  • 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.)