运行 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 anymore; 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 anymore.

  • 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 (should that happen, run corepack enable again to add them back).