I’m trying to use pnpm (nodePackages.pnpm) with nodejs 18. I tried using a shell.nix, a flake.nix and nix-shell -p nodePackages.pnpm. In all three scenarios it uses nodejs 14.
I tried to adapt this workaround for yarn and added an overlay (see below) but the result was, that pkgs.nodePackages only contained pnpm and nothing else. Also, it still used nodejs 14.
let
# Rolling updates, not deterministic.
pkgs = import (fetchTarball("channel:nixpkgs-unstable")) { inherit overlays; };
overlays = [
(self: super: {
nodePackages.pnpm = super.nodePackages.pnpm.override {
nodejs = pkgs.nodejs-18_x;
};
})
];
in pkgs.mkShell {
name = "nix-shell";
packages = with pkgs; [
bashInteractive
nodejs
nodePackages.pnpm
];
}
Something strange I noticed: As soon as I add nodePackages.pnpm to my shell.nix, flake.nix or nix-shell -p, the npm command (not Pnpm) also uses node 14 instead of node 18.
To see the version it uses I added the following script to my package.json
"nv": "node --version",
so that I could get the node version using pnpm nv or npm run nv.
Can anyone please help me to create an overlay that makes pnpm use node 18?
so it uses the 22.05 channel, where pnpm still uses node 14. Then I tried our your solutions:
@kamilchm Your solution seems to be the only one that really works. Could you please explain how you knew how to do this?
@khaled your command works but how would I use it in a shell.nix?
@tennox, this does not work for me when using channel 22.05. Are you sure this should work or was it just a coincidence that unstable used node 16 at the same time? When I use this overlay with 22.05 I still get node 14…
@fzakaria these solutions only “work” for me for the unstable channel. I suspect that is because the unstable channel already uses node 18. Are you sure it also works on 22.05? I can’t get it to work like that.