Install NVM in WSL and Node

 You can install NVM (Node Version Manager) in WSL pretty easily. Here’s the step-by-step:


1. Open your WSL terminal

(For example, Ubuntu).


2. Install required dependencies

sudo apt update
sudo apt install curl wget git -y

3. Download and install NVM

Run the official install script:

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

(Replace v0.39.7 with the latest version if needed: https://github.com/nvm-sh/nvm/releases)


4. Load NVM into your shell

After installation, add this to the end of your ~/.bashrc (or ~/.zshrc if you use Zsh):

export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"

Then reload your shell:

source ~/.bashrc

5. Verify NVM installation

nvm --version

6. Install Node.js using NVM

  • Install latest LTS version:

    nvm install --lts
    
  • Install a specific version:

    nvm install 20
    
  • Switch versions:

    nvm use 20
    

✅ Done — now you can manage multiple Node.js versions in your WSL environment.


Comments

Popular posts from this blog

How to build MCP Server and use MCP Inspector in Node

How to install ngrok in wsl for activepieces