nix - 如何运行 `corepack enable` 来安装 Yarn berry?

标签 nix nix-shell

对于 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/

相关文章:

haskell - 如何在 Nix 中制作 Haskell 开发环境?

haskell - 如何让 cabal 和 nix 一起工作

nix - 如何在 nixos 上安装 systemd 服务

nix - nix-shell '<nixpkgs>' -A gnused 的等效 shell.nix 是什么

shell - 在 nix-shell 中配置 Fish shell 提示符

haskell - 从堆栈项目生成 Nix 包

zsh - NixOS 之外的 Nix 配置