본문 바로가기
OS/Mac

[Mac] NVM (Node Version Manager) 설치

by pcm9881 2023. 11. 9.

Homebrew 설치

brew install nvm

 

결과

==> Downloading https://ghcr.io/v2/homebrew/core/nvm/manifests/0.39.5
Already downloaded: /Users/pcm9881/Library/Caches/Homebrew/downloads/0948392e3d85a4354980add2b7105cb9e5451cfaa01cc29222e9308bba3d50d9--nvm-0.39.5.bottle_manifest.json
==> Fetching nvm
==> Downloading https://ghcr.io/v2/homebrew/core/nvm/blobs/sha256:2290c2b0f95c6ba0c10d18b286bb8e4022126177d356eb395f0db76202df4642
Already downloaded: /Users/pcm9881/Library/Caches/Homebrew/downloads/b66a559402d7bcebd097a4bbfd1b96e7c3fede2a8f1fffdb94cc6f7d3efbc287--nvm--0.39.5.all.bottle.tar.gz
==> Pouring nvm--0.39.5.all.bottle.tar.gz
==> Caveats
Please note that upstream has asked us to make explicit managing
nvm via Homebrew is unsupported by them and you should check any
problems against the standard nvm install method prior to reporting.

You should create NVM's working directory if it doesn't exist:
  mkdir ~/.nvm

Add the following to your shell profile e.g. ~/.profile or ~/.zshrc:
  export NVM_DIR="$HOME/.nvm"
  [ -s "/usr/local/opt/nvm/nvm.sh" ] && \. "/usr/local/opt/nvm/nvm.sh"  # This loads nvm
  [ -s "/usr/local/opt/nvm/etc/bash_completion.d/nvm" ] && \. "/usr/local/opt/nvm/etc/bash_completion.d/nvm"  # This loads nvm bash_completion

You can set $NVM_DIR to any location, but leaving it unchanged from
/usr/local/Cellar/nvm/0.39.5 will destroy any nvm-installed Node installations
upon upgrade/reinstall.

Type `nvm help` for further information.
==> Summary
🍺  /usr/local/Cellar/nvm/0.39.5: 9 files, 192.8KB
==> Running `brew cleanup nvm`...
Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP.
Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).

 

루트 경로에 .nvm 폴더 생성

mkdir ~/.nvm

 

Shell 설정

export NVM_DIR="$HOME/.nvm"
  [ -s "/usr/local/opt/nvm/nvm.sh" ] && \. "/usr/local/opt/nvm/nvm.sh"  # This loads nvm
  [ -s "/usr/local/opt/nvm/etc/bash_completion.d/nvm" ] && \. "/usr/local/opt/nvm/etc/bash_completion.d/nvm"  # This loads nvm bash_completion

 

Shell 설정 반영

zsh

source ~/.zshrc

bash

source ~/.bash_profile

 

 

NVM 설치확인

nvm --version

결과

0.39.5

 

 

NVM Node 설치 가능 목록

nvm ls-remote

NVM Node 설치 가능 목록 (grep 활용 예시: v18 버전)

nvm ls-remote | grep v18

 

NVM Node 설치 된 목록

nvm list

약어

nvm ls

 

NVM Node 설치

NVM Node 최신버전 설치

nvm install node

또는

nvm install --lts

NVM Node 특정버전 설치

nvm install v18.18.2

또는

nvm install 18

 

728x90

댓글