Convert Figma logo to code with AI

Schniz logofnm

🚀 Fast and simple Node.js version manager, built in Rust

17,428
441
17,428
228

Top Related Projects

78,700

Node Version Manager - POSIX-compliant bash script to manage multiple active node.js versions

21,553

Extendable version manager with support for Ruby, Node.js, Elixir, Erlang & more

18,752

Node version management

2,222

Manage multiple NodeJS versions.

10,872

Volta: JS Toolchains as Code. ⚡

Quick Overview

Fnm (Fast Node Manager) is a fast and simple Node.js version manager built in Rust. It allows developers to easily switch between different versions of Node.js, providing a seamless experience for managing multiple projects with varying Node.js version requirements.

Pros

  • Fast performance due to its Rust implementation
  • Cross-platform support (macOS, Windows, Linux)
  • Automatic detection of .nvmrc and .node-version files
  • Shell agnostic with support for Bash, Zsh, Fish, and PowerShell

Cons

  • Relatively newer project compared to alternatives like nvm
  • Limited ecosystem of plugins and extensions
  • May require additional setup for some CI/CD environments
  • Not as widely adopted as some other Node.js version managers

Getting Started

To install fnm, you can use one of the following methods:

# Using Homebrew (macOS and Linux)
brew install fnm

# Using Cargo (Rust package manager)
cargo install fnm

# Using PowerShell (Windows)
scoop install fnm

After installation, add fnm to your shell:

# For Bash/Zsh
eval "$(fnm env --use-on-cd)"

# For Fish
fnm env --use-on-cd | source

# For PowerShell
fnm env --use-on-cd | Out-String | Invoke-Expression

To use fnm, you can run commands like:

# Install the latest Node.js version
fnm install latest

# Use a specific version
fnm use 14

# List installed versions
fnm list

# Set a default Node.js version
fnm default 14.17.0

Competitor Comparisons

78,700

Node Version Manager - POSIX-compliant bash script to manage multiple active node.js versions

Pros of nvm

  • Widely adopted and well-established in the Node.js community
  • Supports a broader range of Node.js versions, including older ones
  • More extensive documentation and community support

Cons of nvm

  • Slower performance, especially when switching between Node.js versions
  • Requires modifying shell configuration files
  • Can potentially interfere with other shell scripts or configurations

Code Comparison

nvm:

nvm install 14.17.0
nvm use 14.17.0
nvm alias default 14.17.0

fnm:

fnm install 14.17.0
fnm use 14.17.0
fnm default 14.17.0

Key Differences

  • Performance: fnm is generally faster than nvm, especially when switching between Node.js versions
  • Installation: fnm is a single binary, while nvm requires shell script installation
  • Language: fnm is written in Rust, while nvm is written in Bash
  • Version support: nvm supports a wider range of Node.js versions, including older ones
  • Cross-platform: fnm has better support for Windows, while nvm is primarily designed for Unix-like systems

Both tools serve the same primary purpose of managing multiple Node.js versions, but fnm focuses on speed and simplicity, while nvm offers more extensive features and broader version support.

21,553

Extendable version manager with support for Ruby, Node.js, Elixir, Erlang & more

Pros of asdf

  • Supports multiple programming languages and tools, not just Node.js
  • Highly extensible with plugins for various languages and tools
  • Consistent interface for managing versions across different technologies

Cons of asdf

  • Steeper learning curve due to its multi-language support
  • Requires installation of plugins for each language/tool
  • May be slower for single-language users compared to specialized tools

Code Comparison

asdf:

asdf plugin add nodejs
asdf install nodejs 14.17.0
asdf global nodejs 14.17.0

fnm:

fnm install 14.17.0
fnm use 14.17.0
fnm default 14.17.0

Key Differences

  • Scope: asdf is a multi-language version manager, while fnm focuses solely on Node.js
  • Installation: asdf requires plugin installation, fnm is ready to use after initial setup
  • Performance: fnm may offer faster operations for Node.js-specific tasks
  • Syntax: asdf uses a consistent syntax across languages, fnm has Node.js-specific commands
  • Community: asdf has a broader community due to its multi-language support, while fnm has a more focused Node.js community

Both tools are effective for managing Node.js versions, but the choice depends on whether you need multi-language support (asdf) or prefer a specialized, potentially faster tool for Node.js (fnm).

18,752

Node version management

Pros of n

  • Simpler installation process, often just a single command
  • Longer project history and larger community, potentially more stable
  • Supports a wider range of Node.js versions, including very old ones

Cons of n

  • Requires root access for global installations, which can be a security concern
  • Less cross-platform compatibility, primarily designed for Unix-like systems
  • Slower version switching compared to fnm's performance

Code Comparison

n:

n 14.17.0
n use 14.17.0 app.js

fnm:

fnm install 14.17.0
fnm use 14.17.0
node app.js

Both tools allow easy version management, but fnm's approach is more explicit in separating installation, use, and execution steps. n combines version selection and execution in a single command, which can be convenient for quick tasks but may lead to less clarity in complex workflows.

fnm's design focuses on performance and cross-platform support, making it a strong choice for developers working across different operating systems or in environments where speed is crucial. n, on the other hand, offers simplicity and a battle-tested approach that many users find comfortable and reliable.

2,222

Manage multiple NodeJS versions.

Pros of nodenv

  • Written in shell script, making it highly portable across Unix-like systems
  • Supports plugin system for extending functionality
  • Integrates well with other *env tools (rbenv, pyenv, etc.)

Cons of nodenv

  • Slower performance compared to fnm, especially on Windows
  • Requires manual installation of Node.js versions
  • Less user-friendly for beginners

Code Comparison

nodenv:

eval "$(nodenv init -)"
nodenv install 14.17.0
nodenv global 14.17.0

fnm:

eval "$(fnm env --use-on-cd)"
fnm install 14.17.0
fnm use 14.17.0

Key Differences

  • fnm is written in Rust, offering faster performance across platforms
  • fnm automatically downloads and installs Node.js versions
  • nodenv requires more manual setup but offers greater customization
  • fnm provides a more streamlined user experience, especially for beginners
  • nodenv integrates better with other version management tools in the *env ecosystem

Both tools effectively manage multiple Node.js versions, but fnm focuses on speed and ease of use, while nodenv prioritizes flexibility and integration with other development tools.

10,872

Volta: JS Toolchains as Code. ⚡

Pros of Volta

  • Written in Rust, offering better performance and memory safety
  • Supports pinning Node.js versions per project, including in CI environments
  • Manages package binaries automatically, eliminating the need for manual PATH adjustments

Cons of Volta

  • Limited support for older Node.js versions (< 10.x)
  • Fewer installation options compared to fnm (no standalone binary)
  • Less flexible in terms of customizing installation locations

Code Comparison

Volta:

volta install node@14.15.0
volta pin node@14.15.0

fnm:

fnm install 14.15.0
fnm use 14.15.0
fnm default 14.15.0

Both Volta and fnm are Node.js version managers, but they differ in implementation and features. Volta focuses on project-level version management and seamless integration with package managers, while fnm emphasizes simplicity and broader version support. Volta's Rust implementation may provide performance benefits, but fnm's broader installation options and flexibility make it more accessible for some users. The choice between the two depends on specific project requirements and personal preferences.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

Fast Node Manager (fnm) Amount of downloads GitHub Actions workflow status

🚀 Fast and simple Node.js version manager, built in Rust

Blazing fast!

Features

🌎 Cross-platform support (macOS, Windows, Linux)

✨ Single file, easy installation, instant startup

🚀 Built with speed in mind

📂 Works with .node-version and .nvmrc files

Installation

Using a script (macOS/Linux)

For bash, zsh and fish shells, there's an automatic installation script.

First ensure that curl and unzip are already installed on you 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 add --skip-shell to install command.

Parameters

--install-dir

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).

--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.

Example:

curl -fsSL https://fnm.vercel.app/install | bash -s -- --install-dir "./.fnm" --skip-shell

Manually

Using Homebrew (macOS/Linux)

brew install fnm

Then, set up your shell for fnm

Using Winget (Windows)

winget install Schniz.fnm

Using Scoop (Windows)

scoop install fnm

Then, set up your shell for fnm

Using Chocolatey (Windows)

choco install fnm

Then, set up your shell for fnm

Using Cargo (Linux/macOS/Windows)

cargo install fnm

Then, set up your shell for fnm

Using a release binary (Linux/macOS/Windows)

Removing

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 <SHELL>

Where <SHELL> can be one of the supported shells:

  • bash
  • zsh
  • fish
  • power-shell

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:

$ node --version
v14.18.3
$ node --version > .node-version

Check out the following guides for the shell you use:

Bash

Add the following to your .bashrc profile:

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

Zsh

Add the following to your .zshrc profile:

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

Fish shell

Create ~/.config/fish/conf.d/fnm.fish and add this line to it:

fnm env --use-on-cd --shell fish | source

PowerShell

Add the following to the end of your profile file:

fnm env --use-on-cd --shell power-shell | Out-String | Invoke-Expression
  • For macOS/Linux, the profile is located at ~/.config/powershell/Microsoft.PowerShell_profile.ps1
  • On Windows to edit your profile you can run this in a PowerShell
    notepad $profile
    

Windows Command Prompt aka Batch aka WinCMD

fnm is also supported but is not entirely covered. You can set up a startup script 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
  • Add it to the startup script
:: %CMDER_ROOT%\config\user_profile.cmd
call "%CMDER_ROOT%\bin\fnm_init.cmd"

You can replace %CMDER_ROOT% with any other convenient path too.

Configuration

See the available configuration options for an extended configuration documentation

Usage

See the available commands for an extended usage documentation

Contributing

PRs welcome :tada:

Developing:

# Install Rust
git clone https://github.com/Schniz/fnm.git
cd fnm/
cargo build

Running Binary:

cargo run -- --help # Will behave like `fnm --help`

Running Tests:

cargo test