The following are instructions for using the node rtx core plugin. This is used when there isn't a git plugin installed named "node".
If you want to use asdf-nodejs or
rtx-node then run rtx plugins install node GIT_URL
.
The code for this is inside the rtx repository at ./src/plugins/core/node.rs
.
The following installs the latest version of node-20.x and makes it the global default:
$ rtx use -g node@20
Behind the scenes, rtx uses node-build
to install pre-compiled binaries and compile from source if necessary. You can check its README for additional settings and some troubleshooting.
node-build
already has a handful of settings, in additional to that rtx-node
has a few extra configuration variables:
RTX_NODE_VERBOSE_INSTALL
[bool]: Enables verbose output for downloading and building.RTX_NODE_FORCE_COMPILE
[bool]: Forces compilation from source instead of preferring pre-compiled binariesRTX_NODE_CONCURRENCY
[uint]: How many jobs should be used in compilation. Defaults to half the computer coresRTX_NODE_DEFAULT_PACKAGES_FILE
[string]: location of default packages file, defaults to$HOME/.default-npm-packages
NODEJS_ORG_MIRROR
[string]: (Legacy) overrides the default mirror used for downloading the distibutions, alternative to theNODE_BUILD_MIRROR_URL
node-build env var
rtx-node can automatically install a default set of npm packages right after installing a node version. To enable this feature, provide a $HOME/.default-npm-packages
file that lists one package per line, for example:
lodash
request
express
You can specify a non-default location of this file by setting a RTX_NODE_DEFAULT_PACKAGES_FILE
variable.
rtx uses a .tool-versions
or .rtx.toml
file for auto-switching between software versions. To ease migration, you can have also have it read an existing .nvmrc
or .node-version
file to find out what version of Node.js should be used. This will be used if node
isn't defined in .tool-versions
/.rtx.toml
.
We provide a command for running the installed node-build
command:
rtx node node-build --version
node-build
has some additional variations aside from the versions listed in rtx ls-remote node
(chakracore/graalvm branches and some others). As of now, we weakly support these variations. In the sense that they are available for install and can be used in a .tool-versions
file, but we don't list them as installation candidates nor give them full attention.
Some of them will work out of the box, and some will need a bit of investigation to get them built. We are planning in providing better support for these variations in the future.
To list all the available variations run:
rtx node node-build --definitions
Note that this command only lists the current node-build
definitions. You might want to update the local node-build
repository before listing them.
Every new node version needs to have a definition file in the node-build
repository.
rtx-node
already tries to update node-build
on every new version installation, but if you
want to update node-build
manually for some reason you can clear the cache and list the versions:
rtx cache clean
rtx ls-remote node
You cannot install/use a plugin named "nodejs". If you attempt this, rtx will just renamed it to "node". See the FAQ for an explanation.