How to use `pnpm` with recent nodejs?

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.

    # 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; [

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?

Hosted by Flying Circus.