📜  nvm for mac (1)

📅  最后修改于: 2023-12-03 15:33:15.577000             🧑  作者: Mango

NVM for Mac

NVM (Node Version Manager) is a tool that makes it easy to install and manage multiple versions of Node.js on a single machine. In this guide, we'll go over the installation process for NVM on Mac.

Installation

Note: You must have Homebrew installed to use the recommended installation method for NVM.

  1. Open your terminal and run the following command to install NVM:
brew install nvm
  1. Once NVM is installed, run the following command to add NVM to your shell profile script:
echo 'export NVM_DIR="$HOME/.nvm"' >> ~/.bash_profile
echo 'source $(brew --prefix nvm)/nvm.sh' >> ~/.bash_profile
  1. Close and re-open your terminal for the changes to take effect.
Commands

NVM comes with several useful commands that make it easy to manage different Node.js versions. Here are a few examples:

  • Install a specific version of Node.js:
nvm install 14.16.0
  • Use a specific version of Node.js:
nvm use 14.16.0
  • List all installed versions of Node.js:
nvm ls
  • Set a default version of Node.js:
nvm alias default 14.16.0
Conclusion

NVM is a powerful tool that simplifies the process of managing multiple versions of Node.js on your Mac. With just a few simple commands, you can easily switch between different versions of Node.js, install new versions, and manage your environment with ease. If you're a Node.js developer, NVM is a must-have tool in your toolkit!