对于 Yarn 的现代版本,又名 Yarn Berry,首选安装是通过 Corepack,Corepack 默认包含在 Node.js 安装中 (>=16.10)。参见 https://yarnpkg.com/getting-started/install
这是我在 default.nix
中尝试做的corepack enable
,但它不起作用。
with import <nixpkgs> {};
stdenv.mkDerivation {
name = "dev";
dontUnpack = true;
buildInputs = [ nodejs-17_x ];
postPhases = ''
corepack enable
'';
}
最佳答案
对于通过搜索引擎最终来到这里的任何其他人:)
corepack enable
corepack prepare yarn@3.2.2 --activate
(安装符号链接(symbolic link)需要enable
,prepare + activate 设置正确的版本。)
这应该适用于 v16.9.0+(甚至 v14.19.0+)
来源:https://nodejs.org/api/corepack.html#upgrading-the-global-versions
关于nix - 如何运行 `corepack enable` 来安装 Yarn berry?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71971941/