[Dev] nvm install (MAC)steemCreated with Sketch.

in hive-101145 •  2 years ago 

안녕하세요 @realmankwon 입니다.

node.js 및 npm 버전을 변경해야 할때가 많아서 nvm을 설치하기로 하였습니다.

일단 brew를 이용해 nvm을 설치해 줍니다.

  • brew install nvm

아래와 같이 메세지가 나옵니다.
이때 잘 읽어보시면 해야할 것들이 나옵니다.

==> Downloading https://ghcr.io/v2/homebrew/core/nvm/manifests/0.39.2
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/nvm/blobs/sha256:d76a0d093ab555e00c7453ac06cb69d9eadce49588d5e5830a332d18e09b1ce2
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sha256:d76a0d093ab555e00c7453ac06cb69d9eadce49588d5e5830a332d18e09b1ce2?se=202
######################################################################## 100.0%
==> Pouring nvm--0.39.2.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 ~/.zshrc or your desired shell
configuration file:

  export NVM_DIR="$HOME/.nvm"
  [ -s "/opt/homebrew/opt/nvm/nvm.sh" ] && \. "/opt/homebrew/opt/nvm/nvm.sh"  # This loads nvm
  [ -s "/opt/homebrew/opt/nvm/etc/bash_completion.d/nvm" ] && \. "/opt/homebrew/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
/opt/homebrew/opt/nvm will destroy any nvm-installed Node installations
upon upgrade/reinstall.

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

따라해야 할 것은 다음과 같습니다.

  • mkdir ~/.nvm
  • vi ~/.zshrc(사용하고 있는 shell의 설정파일을 쓰시면 됩니다.)

shell의 설정 파일에 다음을 추가합니다.

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

다음의 명령어로 반영시킵니다.

  • source ~/.zshrc

그러면 다음과 같이 설치가 된 것을 확인할 수 있습니다.

nvm을 이용해서 node를 설치하고자 할 경우 설치 가능한 버전을 확인합니다.

  • ls-remote (전체목록)
  • ls-remote --lts (Long Term Support 목록)

해당 목록에서 설치하고자 하는 버전을 선택하고 다음과 같이 입력하면 설치가 됩니다.

  • nvm install v14.21.1

현재 설치된 버전을 확인하기 위해서는 다음의 명령어를 사용합니다.

  • nvm ls

설치된 버전 중 사용할 버전을 선택하는 것은 다음의 명령어를 사용합니다.

  • nvm use V14.21.1

다시 열코딩을!!!!

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!
Sort Order:  

image.png

Upvoted! Thank you for supporting witness @jswit.