Files
code-snippets/docs/node/managing-versions.md
Liam Pietralla 80031f13b4
All checks were successful
Build, Test & Publish / Build (pull_request) Successful in 1m0s
Build, Test & Publish / Build and Publish Container Image (pull_request) Has been skipped
Build, Test & Publish / Deploy to Infrastructure (pull_request) Has been skipped
node docs and switch to pnpm
2026-03-04 07:34:58 +11:00

62 lines
2.1 KiB
Markdown

# Managing Node Versions
Managing node versions is important for ensuring that different projects can run with the appropriate version of Node.JS.
Classically I used two different tools to manage node versions:
* **NVM** - a set of bash scripts for MacOS and Linux and
* **NVM-Windows** - a command line utility for Windows.
This quickly grew annoying as they operated slightly differently, and on Windows I like to use multiple accounts to split work and personal projects, which was not compatible with NVM-Windows.
## The Solution: mise-en-place ( or just "mise" )
Mise is a cross-platform tool for managing a wide range of development tools, including Node.JS. Being cross-platform, it works the same way on both Windows and Unix-based systems, making it easier to manage node versions across different environments. It also allows for per-project node versions, which is a great feature for ensuring that each project uses the correct version of Node.JS without affecting other projects.
### Installation
Install Mise using your package manager of choice depending on your operating system:
```bash
brew install mise # For MacOS
winget install jdx.mise # For Windows
sudo add-apt-repository -y ppa:jdxcode/mise && sudo apt update -y && sudo apt install -y mise # For Ubuntu/Debian
```
### Activation
Mise needs to be activated in your shell configuration file. Add the following line to your `.bashrc`, `.zshrc`, or equivalent shell configuration file:
```bash
echo 'eval "$(mise activate zsh)"' >> ~/.zshrc # For Zsh
echo 'eval "$(mise activate bash)"' >> ~/.bashrc # For Bash
```
or windows:
```powershell
# create profile if it doesn't already exist
if (-not (Test-Path $profile)) { New-Item $profile -Force }
# open the profile
Invoke-Item $profile
# add this line
(&mise activate pwsh) | Out-String | Invoke-Expression
```
### Usage
Install Node globally:
```bash
mise use --global node@24
```
Install Node for a specific project:
```bash
cd my-project
mise use node@18
```
When installed in a project Mise will generate a project file in the directory, meaning other users can simply run `mise use` to get the correct version of Node.JS for that project.