Install & Update Script
To install nvm, download the install script and make it executable.
1 | chmod +x install.sh |
Since macOS 10.15, the default shell is zsh
and nvm will look for .zshrc
to update, none is installed by default. Create one with touch ~/.zshrc
:
1 | touch ~/.zshrc |
Add the source lines to .zshrc
profile file:
1 | export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")" |
Verify your installation
You can verify that NVM is installed by running:
1 | nvm --version |
Install Node.js using NVM
1 | $ nvm use 16 |
Troubleshooting
If you have this error:
1 | mkdir: /Users/rainyjune/.nvm/alias: Permission denied |
Change permission on the .nvm
directory:
1 | sudo chmod -R 777 ~/.nvm |
yarn corepack error: “Error when performing the request to https://registry.npmjs.org/yarn/latest“, please run the command below in your terminal:
1 | export COREPACK_NPM_REGISTRY=https://registry.npmmirror.com |