⚡ Manage Node.js Versions Easily with NVM

Need to switch between different Node.js versions for different projects? NVM (Node Version Manager) makes it quick and painless. With just a few commands, you can install, switch, and manage multiple Node versions on your system.

Let’s get right to it — installation, usage, and some handy tips.

🔧 What is NVM?

NVM is a CLI tool to manage multiple Node.js versions — perfect for switching between projects or testing on different versions.

✅ NVM supports:
Windows, Linux, macOS, WSL, Cygwin, and MSYS

📦 Installation/Setup

⚠ Always restart your terminal after installation or configuration changes

On macOS/Linux:

  • Install NVM using curl or wget:

    curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
    

    Or:

    wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
    
  • Add to your shell config (if not auto-added):

    export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")"
    [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
    

    Then reload your shell:

    source ~/.bashrc  # or ~/.zshrc, depending on your shell
    
  • To verify installation:

    nvm --version
    

    Screenshot 2025-04-19 234301.jpg

On Windows:

NVM-Windows (Recommended)

https://github.com/coreybutler/nvm-windows

⬇️ [ Download nvm for windows ]

  • Download the .exe installer.
  • Run it and follow the setup steps.
  • Open a new terminal and check:
nvm --version

That's it! You're ready to manage Node.js versions on Windows.

Other Version Available for Node.js Version Managers for Windows

  • nodist – Manages Node and npm versions.
  • nvs – Cross-platform manager with auto-switch and profiles.

🚀 Using NVM to Manage Node.js

  • Check nvm version

    nvm --version
    
  • Install a Specific Node.js Version

    nvm install <node specific version>
                or 
    nvm install --lts
                or 
    nvm install node
    
  • List Installed Versions

    nvm ls or nvm ls-remote
    
  • Switch Between Node Versions

    nvm use 16
    
  • Set a default version globally:

    Set a default version globally:
    
  • Update Node to the Latest Version

    nvm install node --reinstall-packages-from=current
    nvm alias default node
    
  • Show the currently active Node.js version

    nvm current
    
  • Run a file using a specific Node.js version

    nvm run <version> <file.js>
    usage: nvm run 14 app.js
    
  • Execute a command using a specific Node.js version

    nvm exec <version> <command>
    usage: nvm exec 16 npm install
    
  • Show the path to the Node.js binary for a version

    nvm which <version>
    nvm which 18
    
  • Uninstall a Version

    nvm uninstall 14.21.3
    

⚙️ Using Into project directory

  • If need to switch version for project using node:
    Use a .nvmrc file in your project directory to specify which Node version it requires:

    echo "18.17.1" > .nvmrc
    

    Then:

    nvm use
    

    Based on .nvmrc config file you want to change version runtime need to use node version switch with tool like https://github.com/wbyoung/avn [auto version switching]

    To install avn and its plugin for nvm:

    npm install -g avn avn-nvm avn-n
    avn setup
    

    Let’s focus on writing code — version conflicts? NVM’s got it covered! 😉