How to install NVM (mac, linux)

~Editor

TL;DR

execute NVM installer script,

Execute the following command to execute the NVM installer

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash

To edit your shell config file, execute the following code in your terminal

nano ~/.zshrc

If you are using bash shell, you should use nano ~/.bash_profile instead

Then paste the following script in the your config file, which is being edited.

export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")" [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"

Depending on your system configuration, NVM_DIR will point to either the standard location ~/.nvm or the location specified by XDG_CONFIG_HOME.

Press ctrl + s then ctrl + x to save and close nano editor. Then execute the following command to source your configuration

source ~/.zshrc

*remember to source ~/.bash_profile (if youre working on bash instead)

Check if the setup is successful

nvm -v