DEV Community

Beaver Bridge
Beaver Bridge

Posted on

nvm으로 node 버전 관리하기

node를 brew로 설치해서 사용하고, brew upgrade 를 자주 실행해서 node가 항상 최신 버전이다. 근데 개발한 프로그램이 나한테서만 로그인이 안되는 문제가 발생해서 찾아보니 내 node 버전이 너무 높은게 원인이었다.

안그래도 node 버전은 lts를 써야한다 라는 얘기는 들었지만, 이렇게 문제가 발생할 줄은 몰랐다. 이참에 nvm으로 갈아탄다.

nvm 설치

https://github.com/nvm-sh/nvm

$ arch -arm64 brew install nvm
Enter fullscreen mode Exit fullscreen mode

설치 후에 나오는 설명대로 폴더를 만든다.

$ mkdir ~/.nvm
Enter fullscreen mode Exit fullscreen mode

.zshrc에 추가

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
Enter fullscreen mode Exit fullscreen mode

설치가능한 목록 보기

$ nvm list
->     v18.19.1
default -> v18.19.1
iojs -> N/A (default)
unstable -> N/A (default)
node -> stable (-> v18.19.1) (default)
stable -> 18.19 (-> v18.19.1) (default)
lts/* -> lts/iron (-> N/A)
lts/argon -> v4.9.1 (-> N/A)
lts/boron -> v6.17.1 (-> N/A)
lts/carbon -> v8.17.0 (-> N/A)
lts/dubnium -> v10.24.1 (-> N/A)
lts/erbium -> v12.22.12 (-> N/A)
lts/fermium -> v14.21.3 (-> N/A)
lts/gallium -> v16.20.2 (-> N/A)
lts/hydrogen -> v18.19.1
lts/iron -> v20.11.1 (-> N/A)
Enter fullscreen mode Exit fullscreen mode

node 설치

https://github.com/nvm-sh/nvm?tab=readme-ov-file#long-term-support

$ nvm install --lts # or nvm install v20.11.1
$ nvm use --lts # or nvm use v20.11.1
Enter fullscreen mode Exit fullscreen mode

기본 버전 지정

이걸 안하면 터미널이 새로 실행되면 node -v 를 해도 command not found 가 뜬다.

$ nvm alias default node # or nvm alias default 20.11.1
Enter fullscreen mode Exit fullscreen mode

Speedy emails, satisfied customers

Postmark Image

Are delayed transactional emails costing you user satisfaction? Postmark delivers your emails almost instantly, keeping your customers happy and connected.

Sign up

Top comments (0)

nextjs tutorial video

Youtube Tutorial Series 📺

So you built a Next.js app, but you need a clear view of the entire operation flow to be able to identify performance bottlenecks before you launch. But how do you get started? Get the essentials on tracing for Next.js from @nikolovlazar in this video series 👀

Watch the Youtube series

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay