Looking for a Node.js version manager that works cross-platform, might be worth trying out fnm.

1. Why fnm? I’ve previously used Node Version Manager (NVM) on macOS and Linux machines, but recently switched back to using my Windows machine. While there is a NVM for Windows, I noticed that the Node.js installation instructions used something called fnm.

2. What is fnm? Fast Node Manager (fnm) is a Node.js version manager, designed to be lightweight and efficient due to its development in Rust. Unlike nvm, which provides more features such as support for multiple languages and global binaries, fnm focuses on providing a simple and fast Node.js version manager.

3. Commands Overview: fnm comes with familiar commands for version and package management:

Commands:
    list-remote  List all remote Node.js versions [aliases: ls-remote]
    list         List all locally installed Node.js versions [aliases: ls]
    install      Install a new Node.js version [aliases: i]
    use          Change Node.js version
    env          Print and set up required environment variables for fnm
    completions  Print shell completions to stdout
    alias        Alias a version to a common name
    unalias      Remove an alias definition
    default      Set a version as the default version
    current      Print the current Node.js version
    exec         Run a command within fnm context
    uninstall    Uninstall a Node.js version [aliases: uni]
    help         Print this message or the help of the given subcommand(s)

You can find more details on the commands and options.

4. Getting Started with fnm: It's probably best to uninstall any previous Node.js versions before getting started.

Installation:

Windows:

  • Install using winget by running the following in PowerShell:
    winget install Schniz.fnm
    

Linux/macOS:

  • The easiest option is to use the install script:
    curl -fsSL https://fnm.vercel.app/install | bash
    

Shell Setup: Once installed, the shell needs setting up. If the install script wasn't run, then follow these steps:

Bash:

eval "$(fnm env --use-on-cd --shell bash)"

Zsh:

eval "$(fnm env --use-on-cd --shell zsh)"

Windows/PowerShell: After installation, open a new PowerShell window. If fnm is not recognized, run:

fnm env --use-on-cd --shell powershell | Out-String | Invoke-Expression

5. Managing Node.js Versions with fnm:

  • Check installed Node.js versions:

    fnm list
    
  • See available Node.js versions for download:

    fnm list-remote
    
  • Install a specific version (e.g., version 20):

    fnm install 20
    
  • Install the latest version (e.g., version 22):

    fnm install 22
    
  • Install a specific version by number (e.g., 19.8.1):

    fnm install 19.8.1
    
  • Use a specific version:

    fnm use 20
    
  • Download and use Node.js in one go:

    fnm use --install-if-missing 22
    

Using fnm makes managing Node.js versions a breeze. Whether you're switching between projects with different requirements or just want to try out the latest features, fnm has you covered.