---
tags:
  - nodejs
  - javascript
  - development
  - guide
  - linux
  - nvm
---

# Setting up a Node.js Development Environment

This guide covers the professional way to set up a Node.js environment on Linux using **Node Version Manager (nvm)**. Using `nvm` allows you to install multiple versions of Node.js and switch between them effortlessly, which is essential for working on different projects with different requirements.

## 1. Prerequisites

The `nvm` installation script requires `curl` or `wget` to download. Ensure you have these installed by following the initial post-install configuration.

*   **Reference:** [[Post-Install-Config|Post-Install Linux Configuration]]

## 2. Install Node Version Manager (nvm)

1.  Open your terminal.
2.  Run the official installation script. This command downloads and executes the script from the `nvm` GitHub repository.
    ```bash
    curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
    ```
    *(Note: Always check the official nvm repository for the latest version number and command).*

3.  **Reload your shell** for the changes to take effect. You can either close and reopen your terminal or run:
    ```bash
    source ~/.bashrc
    ```

4.  **Verify installation:**
    ```bash
    command -v nvm
    ```
    If this command outputs `nvm`, the installation was successful.

## 3. Install Node.js

With `nvm` installed, you can now install Node.js. It's best practice to start with the latest **Long-Term Support (LTS)** version.

```bash
nvm install --lts
```

`nvm` will download, compile, and install the latest stable LTS release of Node.js and set it as your default.

## 4. Verification

Check that `node` and its package manager, `npm`, are ready to use.

```bash
node -v
npm -v
```
These commands should return the version numbers of the installed software (e.g., `v20.11.0` and `10.2.4`).

## 5. Managing Multiple Versions

The power of `nvm` comes from managing different project needs.

*   **Install a specific version:** `nvm install 18.19.0`
*   **List all installed versions:** `nvm ls`
*   **Switch to another version for your current session:** `nvm use 18.19.0`
*   **Set a default version for all new shells:** `nvm alias default 20.11.0`