# Multiple Node.js versions on Windows: absolute paths beat nvm

> Use nvm-windows for the CLI, but pin each service to an absolute node.exe so a global switch cannot break production.

**Tested on**

- Build: 26100.33650
- Edition: Standard / Datacenter
- Architecture: x64
- Evidence: E1
- Verified: 2026-10-29

## The short answer

`nvm-windows` switches a **global symlink** (`C:\Program Files\nodejs`). That is fine for your shell, dangerous for services.

For multiple apps:

1. Install each Node version in its own directory (`C:\node\20`, `C:\node\22`).
2. Pin the service/script to the absolute `node.exe`.
3. Use the matching `npm.cmd` from that directory.
4. Keep `node_modules` per app; do not share global packages.

## CLI layout

```powershell
nvm list
nvm install 22.14.0
nvm use 22.14.0
where.exe node
node --version
```

After `nvm use`, `where node` points at the active symlink. That is convenient for development; it is not a production selector.

## Per-app layout

```text
C:\node\20\node.exe
C:\node\22\node.exe
C:\apps\api-a\server.js
C:\apps\api-b\server.js
```

Run:

```powershell
& C:\node\20\node.exe C:\apps\api-a\server.js
& C:\node\22\node.exe C:\apps\api-b\server.js
```

The service wrapper must use the same absolute path. A service created with `node` resolves through PATH at start time; after an nvm switch it can silently use the wrong version.

## Dependencies

```powershell
cd C:\apps\api-a
& C:\node\20\npm.cmd ci --omit=dev
```

Use `npm ci` with a lockfile for repeatable installs. Do not `npm install -g` app dependencies; global packages are shared and versionless.

## Verify

```powershell
& C:\node\20\node.exe --version
& C:\node\20\npm.cmd --version
Get-CimInstance Win32_Process -Filter "Name='node.exe'" |
  Select-Object ProcessId, ExecutablePath, CommandLine
```

`ExecutablePath` should show the pinned version, not the nvm symlink.

> **Caution: A global switch is a production incident**
>
> If two services both resolve `node` from PATH, `nvm use` can change both on their next restart. Pin absolute paths and document them in the service definition.

## Upgrade path

1. Install the new Node beside the old.
2. Run the app’s test suite with the new absolute `node.exe`.
3. Update the service wrapper path.
4. Restart one service; watch logs and metrics.
5. Keep the old directory until rollback is no longer needed.

## Lab boundary

E1. The lab did not install Node or nvm-windows; the procedure is the production selector pattern, not a reproduced result.

## Sources

- [nvm-windows](https://github.com/coreybutler/nvm-windows)
- [Node.js — downloads](https://nodejs.org/en/download)
- [Node.js — packages and CI](https://docs.npmjs.com/cli/v10/commands/npm-ci)

---

Source: https://winbook.fyi/en/server/runtimes/node-multi-version/
