In this article I will share with you the steps on how to install NVM and Node.js in macOS using HomeBrew.
HomeBrew is an open-source software package management system that simplifies the installation of software on your macOS. It is like the ‘apt’ in Linux.
Install HomeBrew
If your macOS is not yet install with HomeBrew, you can install it by issuing this command in your Terminal.
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Once you have HomeBrew installed, then you can start install NVM and Node.js in your machine.
Install NVM with HomeBrew
First, we will install NVM in HomeBrew by using this command in the Terminal.
brew install nvm
Then you need to create NVM folder in your Home directory.
mkdir ~/.nvm
And next, add the following in your shell ~/.profile or ~/.zshrc file. In my case, I’m using .zshrc for my shell.
export NVM_DIR="$HOME/.nvm" [ -s "$HOMEBREW_PREFIX/opt/nvm/nvm.sh" ] && \. "$HOMEBREW_PREFIX/opt/nvm/nvm.sh" # This loads nvm [ -s "$HOMEBREW_PREFIX/opt/nvm/etc/bash_completion.d/nvm" ] && \. "$HOMEBREW_PREFIX/opt/nvm/etc/bash_completion.d/nvm" # This loads nvm bash_completion
Now, you can restart your Terminal to use this new config.
You can check is your NVM is working or not by checking its version.
nvm -v #Output: 0.39.3
Install Node.js with NVM
It is recommended to install Node.js using NVM and not Homebrew.
Just enter this command to install the latest Node.js version in your machine.
nvm install node
Once installed, you can check the version with this command.
node -v #Output: v20.3.1
That’s it! Now you can start developing your webapp with NVM and Node.js.
Good luck!
Leave a Reply