System-wide installation of multiple Node.js versions

I’d like it to work nicely with IDE(s) such as WebStorm. What’s idiomatic way to do it in NixOS?


Auto-downloaded Node.js is not working, and gives error:

❯ which node
/home/miroslav/.config/JetBrains/WebStorm2025.1/node/versions/20.15.0/bin/node

❯ node
Could not start dynamically linked executable: node
NixOS cannot run dynamically linked executables intended for generic
linux environments out of the box. For more information, see:
https://nix.dev/permalink/stub-ld

And, therefore automatic project setups via IDE with its auto-downloaded Node.js don’t work.


So far, I have been using per-project nix shells. And, it mostly works well.

However, it requires some amount of boilerplate to setup, and it’s a developer’s OS specific setup.

And, I’m wondering whether there’s some “convention over configuration” approach, that picks up versions automatically from .nvmrc, .npmrc

What do you use? Or, do you go with nix-shells?

One not-sure-whether-ideal solution, that I’ve hand-crafted is this NixOS config:

{ config, pkgs, ... }:

let
  nodeJsMulti= pkgs.runCommand "nodejs-env" {
    buildInputs = with pkgs; [
      nodejs_20
      nodejs_22
      nodejs_24
    ];
  } ''
    mkdir -p $out/nodejs
    ln -s ${pkgs.nodejs_20} $out/nodejs/20
    ln -s ${pkgs.nodejs_22} $out/nodejs/22
    ln -s ${pkgs.nodejs_24} $out/nodejs/24
  '';
in {
  environment.pathsToLink = [ "/nodejs" ];

  environment.systemPackages = [
    # to get /run/current-system/sw/nodejs/ populated
    nodeJsMulti
  ];

  system.activationScripts.nodeJsOptSymlink.text = ''
    mkdir -p /opt
    chmod 755 /opt

    ln -sfT /run/current-system/sw/nodejs /opt/nodejs
  '';
}

You can use nix-ld

You could also write derivations that download the binaries from Node’s website and patchelfs them (this is what rust-overlay does). Which also means you don’t depend on which Node versions are available in Nixpkgs anymore.