You can install the NVM binary with curl
or using Homebrew
.
brew install nvm
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.2/install.sh | bash
The above command downloads the install.sh
script from the specified URL and runs it using the
bash
shell. When this command is executed, it will download and run the
install.sh
script, which will automatically install NVM on your system and configure it in your shell.
This allows you to use the nvm
command to manage and switch between different versions of Node.js.
If the configuration is not done automatically, add the following lines to your shell profile file
(e.g., ~/.bashrc
, ~/.zshrc
, or ~/.bash_profile
):
export NVM_DIR=~/.nvm
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"
Hint: Use echo $0
to Identify Your Shell Profile
After installing NVM, restart your terminal or open a new terminal window. This is necessary for the changes made by NVM to take effect.
If the NVM configuration is not set in your shell profile, use the following command to use NVM:
source ~/.nvm/nvm.sh
nvm ls
nvm use <version number>