I’m trying to set up a nix dev shell with nodejs and a node module rush, but I have a problem.
Installing the nodejs
package from nixos unstable currently gives me version v20.11.1. This is fine, but running rush update
fails because it does not support the v20 node. I want to keep using node v20 in my dev shell, but let nodePackages.rush
use a slightly older node version that’s supported.
I tried something like this:
{
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs, flake-utils }:
flake-utils.lib.eachDefaultSystem
(system:
let
pkgs = import nixpkgs {
inherit system;
};
in
with pkgs;
{
devShells.default = mkShell {
packages = with pkgs; [
nodejs
(nodePackages.rush.override { nodejs = nodejs-18_x; })
];
};
}
);
}
This is the error I get. As you can see rush
is still using the v20 node. How can I properly override the node version used for a particular package?
❯ rush update
Rush version 5.113.4 is not currently installed. Installing...
Trying to acquire lock for rush-5.113.4
Deleting old files from /home/user/.rush/node-v20.11.1/rush-5.113.4
Transforming /home/user/projects/test/common/config/rush/.npmrc
--> "/home/user/.rush/node-v20.11.1/rush-5.113.4/.npmrc"
Running "npm install" in /home/user/.rush/node-v20.11.1/rush-5.113.4
Successfully installed Rush version 5.113.4 in /home/user/.rush/node-v20.11.1/rush-5.113.4.
Rush Multi-Project Build Tool 5.113.4 - https://rushjs.io
Node.js version is 20.11.1 (LTS)
ERROR: Your dev environment is running Node.js version v20.11.1 which does not meet the requirements for
building this repository. (The rush.json configuration requires nodeSupportedVersionRange=">=14.15.0
<15.0.0 || >=16.13.0 <17.0.0 || >=18.15.0 <19.0.0")