CCing Michael from the node.js upstream to share his opinion on this idea as well.

Honza

On Tue, Jul 11, 2023 at 5:17 PM Honza Horak <hhorak@redhat.com> wrote:
The current implementation of alternative nodejs versions in a single Fedora (say 38), is this:
* the main version (v18 in F38) ships /usr/bin/node
* alternative versions ship only /usr/bin/node-XX

Node modules packaged as RPM (e.g. nodejs-nodemon) then often include this hard dependency: Requires: /usr/bin/node

Suppose I want to install only the alternative (non-default) version of node and install a module nodejs-nodemon (that can run fine with any nodejs version). I cannot do this at this point, because the nodejs-nodemon pulls in the default node as a dependency.

New proposal: use a concept that has proofed to work for ruby for longer time (except it's used for alternative implementations, rather than alternative versions, but the logic is similar) -- rubypick package ships /usr/bin/ruby that is actually a simple shell script. This script executes a particular binary of ruby based on a reasonable defaults, explicit parameters of environment variables.

How it would work for node:
The default nodejs version would ship a new sub-package called "nodepick", which would only ship a couple of shell scripts: /usr/bin/node, /usr/bin/npm, etc.. All nodejs versions (including the default one) would only ship versioned binaries /usr/bin/node-XX. The shell scripts would execute a particular versioned binary based on some reasonable logic (environment variables, default, available version)...

From the RPM metadata perspective:
There would need to be some soft dependency from nodepick -> node-XX, with priority for the default version (dnf honours priority by Suggests I think), and a hard dependency of each of the nodejs-XX -> nodepick.

Thoughts?

Honza