Jika anda bingung ketika switch node version ini solusinya.
Contoh kasus project lama masih menggunakan versi 10 sedangkan ada project baru yg node versinya 16. awalnya ane pake virtualbox..hehe tp partner ngasih tau bahwa bisa switch node versi pake NVM (Node Version Manager) :
Install NVM Mac
- Kalo belum install dulu nih :
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
- Remove jika sudah ada node, installnya nanti dari brew
brew uninstall --ignore-dependencies node
brew uninstall --force node
- Install pake brew
brew update
brew install nvm
- Create a directory for NVM in home
mkdir ~/.nvm
- Configure the required environment variables. Bisa pake vim atau nano, atau editor lain
nano ~/.bash_profile
add config
export NVM_DIR=~/.nvm source $(brew --prefix nvm)/nvm.sh
- Load variables
source ~/.bash_profile
- Lihat versi node
nvm ls-remote
- Install node
nvm install node // latest version
nvm install 16 // stable version
- Cek versi current
nvm ls
- Switch ke node versi lain
nvm use 14
Versi Windows
Download file pilih yang nvm-setup.zip
Extract terus install sampe selesai
Coba buka CMD ketikan nvm. Oke sih harusnya.
- Cek list node yang tersedia
nvm list available
- Install node version
nvm install 16
- Setup default node version
nvm alias default 14.16.0
- Switch ke node versi lain
nvm use 14.16.0 // must complete version
Source:
https://tecadmin.net/install-nvm-macos-with-homebrew/
https://www.petanikode.com/nodejs-nvm/
https://github.com/coreybutler/nvm-windows/releases
Komentar