fnm offers a speedy alternative to the Node.js manager NVM.
Built with native ReasonML, it’s significantly faster than NVM.

fnm Setup

Here’s how I set it up on an Arch-based Linux system that uses the Fish shell as an interactive shell.

Use the installation script from fnm:

$ curl -fsSL https://github.com/Schniz/fnm/raw/master/.ci/install.sh | bash

The command downloads fnm, installs it and adds a loader to bash.
The installation script above adds the following lines to .bashrc:

export PATH="~/.fnm:PATH"
eval "`fnm env --multi`"

I use fish shell as my interactive shell. That means that Linux starts bash, and bash then delegates to the fish shell.
Here’s (part of my) .bashrc:

exec fish

The lines that fnm added to .bashrc won’t work. You can delete them.
Instead, set the fish user path:

$ set -U fish_user_paths ~/.fnm $fish_user_paths

Plus, add this line to the config.fish file:

fnm env --multi | source

Now, fnm is available in fish shell.

Install a node version with fnm install and alias it.

How to install globally available packages across all node versions?

My solution comes from a GitHub issue: minimize globally installed packages, put the necessary packages into a dedicated folder.

Create a folder to hold the globally installed packages, for example ~/.npmbin.

$ npm config set prefix `~/.npmbin`

Now use the normal command to install a package globally with npm install -g. The packages now land in ~/.npmbin/bin.

Add this to $PATH:

$ set -U fish_user_paths ~/.npmbin/bin $fish_user_paths