Fast and simple Node.js version manager, built in Rust
Fast Node Manager (fnm) is a Node.js version management tool designed to streamline the process of switching between different Node.js versions with ease and efficiency. Built in Rust for optimal performance, fnm offers developers a lightweight yet powerful solution for managing their Node.js environments.
Key Features:
Cross-platform support: Works seamlessly on macOS, Windows, and Linux.
Single-file installation: Easy to install and set up without unnecessary dependencies.
Instant startup: Designed with speed in mind for quick environment setup.
Compatibility with .node-version and .nvmrc files: Automatically detects and switches Node.js versions based on project-specific configuration files.
Audience & Benefit: Ideal for developers, DevOps engineers, and anyone working with multiple Node.js projects. fnm provides a fast, reliable way to manage Node.js versions, ensuring consistent environments across teams and projects. With its cross-platform compatibility and lightweight design, it simplifies the process of switching between Node.js versions while maintaining high performance.
fnm can be installed via winget on Windows, making it accessible to users across different operating systems. Its focus on speed, simplicity, and reliability makes it a go-to tool for managing Node.js environments efficiently.
README
Fast Node Manager (fnm)
> ๐ Fast and simple Node.js version manager, built in Rust
Features
๐ Cross-platform support (macOS, Windows, Linux)
โจ Single file, easy installation, instant startup
First ensure that curl and unzip are already installed on your operating system. Then execute:
curl -fsSL https://fnm.vercel.app/install | bash
Upgrade
On macOS, it is as simple as brew upgrade fnm.
On other operating systems, upgrading fnm is almost the same as installing it. To prevent duplication in your shell config file, pass --skip-shell to the install command:
Set a custom directory for fnm to be installed. The default is $XDG_DATA_HOME/fnm (if $XDG_DATA_HOME is not defined it falls back to $HOME/.local/share/fnm on linux and $HOME/Library/Application Support/fnm on MacOS).
> Note: On macOS, this option is only meaningful when using --force-install since Homebrew is the default installation method.
--skip-shell
Skip appending shell specific loader to shell config file, based on the current user shell, defined in $SHELL. e.g. for Bash, $HOME/.bashrc. $HOME/.zshrc for Zsh. For Fish - $HOME/.config/fish/conf.d/fnm.fish
--force-install
macOS installations using the installation script are deprecated in favor of the Homebrew formula, but this forces the script to install using it anyway.
To remove fnm (๐ข), just delete the .fnm folder in your home directory. You should also edit your shell configuration to remove any references to fnm (ie. read Shell Setup, and do the opposite).
Completions
fnm ships its completions with the binary:
fnm completions --shell
Where `` can be one of the supported shells:
bash
zsh
fish
powershell
Please follow your shell instructions to install them.
Shell Setup
Environment variables need to be setup before you can start using fnm.
This is done by evaluating the output of fnm env.
> [!NOTE]
> Check out the Configuration section to enable highly
> recommended features, like automatic version switching.
Adding a .node-version to your project is as simple as:
To create the profile file you can run this in PowerShell:
if (-not (Test-Path $profile)) { New-Item $profile -Force }
To edit your profile run this in PowerShell:
Invoke-Item $profile
Windows Command Prompt aka Batch aka WinCMD
fnm is also supported but is not entirely covered. You can set up a startup script for cmd.exe or Windows Terminal and append the following lines:
@echo off
:: for /F will launch a new instance of cmd so we create a guard to prevent an infnite loop
if not defined FNM_AUTORUN_GUARD (
set "FNM_AUTORUN_GUARD=AutorunGuard"
FOR /f "tokens=*" %%z IN ('fnm env --use-on-cd') DO CALL %%z
)
Usage with Cmder
Usage is very similar to the normal WinCMD install, apart for a few tweaks to allow being called from the cmder startup script. The example assumes that the CMDER_ROOT environment variable is set to the root directory of your Cmder installation.
Then you can do something like this:
Make a .cmd file to invoke it
:: %CMDER_ROOT%\bin\fnm_init.cmd
@echo off
FOR /f "tokens=*" %%z IN ('fnm env --use-on-cd') DO CALL %%z