Specific node version with latest npm

Is it possible to use a specific version of NodeJS, say the current LTS v14.16.1, with the latest version of npm? My nix-based dev env needs to play nicely with others and particular projects have already moved on to npm 7 which has a new package-lock.json format that causes install issues for npm 6.

I was able to include new packages in my python shell like this:

{ pkgs ? import <nixpkgs> { } }:
let
  customPython = pkgs.python38.buildEnv.override {
    extraLibs = [
      pkgs.python38Packages.ipython
      pkgs.python38Packages.ipdb
    ];
  };
in
pkgs.mkShell {
  buildInputs = [
    customPython
  ];
}

But the same thing with node gives errors. Bringing in nodePackages.npm theoretically gets me the latest version of npm installed somewhere but the shell will only use the version that was bundled with nodejs-14_x.

I’m currently trying to install node without npm and nodePackages.npm, based on this article, but it’s compiling from source. :pleading_face:

Please and thank you. :pray:

1 Like