### Debian-Based Systems

#### Step 1: Install Node.js and npm

1. **Update Your Package Index**: Run `sudo apt update` to ensure your package lists are up to date.
2. **Install Node.js and npm**:
   - The easiest way to install Node.js and npm while keeping them updated is to use NodeSource. NodeSource provides more current versions of Node.js than the official Debian repositories.
   - First, download and execute the NodeSource installation script for the Node.js version you want to install. For example, for Node.js 14.x, you would use:
     ```
     curl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash -
     ```
   - Then, install Node.js and npm:
     ```
     sudo apt-get install -y nodejs
     ```
   - This command installs both Node.js and npm, as npm is included in the Node.js package.

#### Step 2: Using nvm (Node Version Manager)

- **nvm** allows you to manage multiple Node.js versions on the same machine, akin to virtual environments in Python.
- Install nvm by running:
  ```
  curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
  ```
- Then, open a new terminal or `source ~/.bashrc` to start using nvm.
- To install a specific version of Node.js and npm, use:
  ```
  nvm install node # for the latest version
  nvm install 14 # for a specific version, e.g., 14
  ```

### macOS

#### Step 1: Install Node.js and npm

- You can install Node.js and npm on macOS using Homebrew, a package manager for macOS.
- If you haven't installed Homebrew yet, run:
  ```
  /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
  ```
- Then, to install Node.js (which will include npm), use:
  ```
  brew install node
  ```

#### Step 2: Using nvm on macOS

- Installing nvm on macOS is similar to Debian. Run:
  ```
  curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
  ```
- After installation, you might need to restart your terminal or run `source ~/.bash_profile` to start using nvm.
- Install and use specific Node.js versions using nvm as described above.

### Best Practices for Setting Up Node.js Projects

1. **Use nvm to Manage Node.js Versions**: Similar to Python's virtual environments, nvm allows you to switch between Node.js versions depending on the project's needs, avoiding version conflicts and ensuring compatibility.

2. **Local Installation of 11ty**: While you can install 11ty globally, it's a good practice to install project-specific tools locally within each project. This approach ensures that your project's dependencies are documented and consistent across environments. Use:
   ```
   npm install --save-dev @11ty/eleventy
   ```
   Then, you can add a script to your `package.json` to build your 11ty site:
   ```json
   "scripts": {
     "build": "eleventy"
   }
   ```
   This allows anyone working with your project to run `npm run build` to build the site with the correct version of 11ty.

3. **Commit Your `package.json` and `package-lock.json`**: These files should be included in your version control system. They lock down the versions of the installed packages, ensuring that all contributors to the project use the same package versions.

4. **.gitignore**: Always add `node_modules/` to your `.gitignore` file. There's no need to commit the installed packages to your version control, as these can be installed by running `npm install` when setting up the project.

Following these steps and best practices, you can set up a clean and manageable Node.js and 11ty environment on both Debian-based systems and macOS, akin to managing Python projects with virtual environments.