Search code examples
yarnpkgnixreplit

How can I synchronize Node and Yarn versions in my nix shell?


I have the following replit.nix file:

{ pkgs }: {
    deps = [
        pkgs.nodejs-17_x
        pkgs.nodePackages.yarn
    ];
}

node -v returns 17.3.1, but yarn node -v returns 14.18.3. I was able to find a corresponding NIX issue, but I am unsure about how to properly set the overlays accordingly. How can I set up my configuration file to synchronize my NodeJS version and my yarn NodeJS version?


Solution

  • Override yarn with a null nodejs value (this also means it can't be a nodePackage):

    { pkgs }: {
        deps = [
            pkgs.nodejs-17_x
            (pkgs.yarn.override {
              nodejs = null;
            })
        ];
    }