# How to Upgrade Node.js on Different Operating Systems

Node.js, a popular [JavaScript](https://bytescrum.com/) runtime, regularly releases updates to improve performance, fix bugs, and add new features. Staying up-to-date ensures compatibility with new libraries and keeps your system secure. Here’s a step-by-step guide on how to upgrade Node.js on **Windows**, **macOS**, and **Linux**.

---

## 1\. Upgrade Node.js on Windows

### Method 1: Using the Node.js Installer

1. Visit the official [Node.js website](https://nodejs.org).
    
2. Download the **latest version** for Windows (LTS or Current, depending on your needs).
    
3. Run the installer:
    
    * Follow the installation wizard.
        
    * It will automatically upgrade your existing Node.js version.
        

### Method 2: Using `nvm-windows` (Node Version Manager for Windows)

1. Download **nvm-windows** from the [release page](https://github.com/coreybutler/nvm-windows/releases).
    
2. Install it and ensure it's added to your PATH.
    
3. Open a new **Command Prompt** or **PowerShell** window and run:
    

---

## 2\. Upgrade Node.js on macOS

### Method 1: Using Homebrew

1. Open **Terminal**.
    
2. Run the following commands:
    
    ```bash
    brew update
    brew upgrade node
    ```
    
3. Verify the version:
    
    ```bash
    node -v
    ```
    

### Method 2: Using `n`

1. Install `n` (a version manager) globally if it’s not already installed:
    
    ```bash
    npm install -g n
    ```
    
2. Use `n` to install the latest version:
    
    ```bash
    n latest
    ```
    
3. Verify the version:
    
    ```bash
    node -v
    ```
    

---

## 3\. Upgrade Node.js on Linux

### Method 1: Using NodeSource Repository (Debian/Ubuntu)

1. Open **Terminal**.
    
2. Add the NodeSource repository:
    
    ```bash
    curl -fsSL https://deb.nodesource.com/setup_current.x | sudo -E bash -
    ```
    
3. Install or upgrade Node.js:
    
    ```bash
    sudo apt-get install -y nodejs
    ```
    
4. Verify the installation:
    
    ```bash
    node -v
    ```
    

### Method 2: Using `n` (for all Linux distros)

1. Install `n` globally:
    
    ```bash
    npm install -g n
    ```
    
2. Use `n` to install the latest version:
    
    ```bash
    sudo n latest
    ```
    
3. Check the installed version:
    
    ```bash
    node -v
    ```
    

### Method 3: Using `nvm` (Node Version Manager)

1. Install or update `nvm` by running:
    
    ```bash
    curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash
    ```
    
2. Restart your terminal or run:
    
    ```bash
    source ~/.bashrc
    ```
    
3. Install the latest Node.js version:
    
    ```bash
    nvm install node
    nvm use node
    ```
    
4. Verify:
    
    ```bash
    node -v
    ```
    

<details data-node-type="hn-details-summary"><summary>Conclusion</summary><div data-type="detailsContent">Upgrading Node.js ensures that your applications run with the latest features and security updates. Whether you're on <strong>Windows</strong>, <strong>macOS</strong>, or <strong>Linux</strong>, you can easily upgrade using package managers, version managers, or installers. Choose the method that best fits your workflow, and make sure to regularly update Node.js to avoid compatibility issues.</div></details>
