# How to Update node.js?

To update Node.js to the latest version, you can use a version manager like NVM (Node Version Manager) or download and install the latest version directly from the official Node.js website.

## Using NVM (Node Version Manager)

If you have NVM installed, updating Node.js is straightforward:

1. Open your terminal.
2. Check the currently installed versions:
    
    ```bash
    nvm ls
    ```
    
3. Install the latest Node.js version:
    
    ```bash
    nvm install node
    ```
    
    This command will install the latest stable version.
    
4. Set the newly installed version as the default:
    
    ```bash
    nvm use node
    ```
    
    Alternatively, you can set it as the default version:
    
    ```bash
    nvm alias default node
    ```
    

## Without NVM

If you don't use NVM, you can update Node.js by downloading and installing the latest version from the official website:

1. Visit the [Node.js Downloads](https://nodejs.org/en/download/) page.
2. Download the LTS (Long-Term Support) version or the latest version based on your preference.
3. Run the installer and follow the installation instructions.

After updating, you can check the installed Node.js version to verify the update:

```bash
node -v
```

This will display the version number of the installed Node.js.

Keep in mind that if you are using any global Node.js packages, you might need to reinstall them after updating Node.js to ensure compatibility. Also, updating Node.js may require restarting your terminal or shell to apply the changes.