node docs and switch to pnpm
This commit is contained in:
62
docs/node/managing-versions.md
Normal file
62
docs/node/managing-versions.md
Normal file
@@ -0,0 +1,62 @@
|
||||
# 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.
|
||||
Reference in New Issue
Block a user