Homebrew installation tutorial please refer to this article written by Hu Zhongjian on Zhihu

M1 chip installed Homebrew tutorial on the Mac – articles – zhihu ineo6 zhuanlan.zhihu.com/p/341831809

Next, I will start the NVM installation. Most of the NVM tutorials on the Internet are downloading NVM using curl, but I cannot visit the Internet website recently. So this tutorial uses Homebrew to install, because the NVM path used for homebrew installation is different from the path used for curl installation, so some configurations are different.

  • First install NVM using brew install NVM command;
% brew install nvm. . . You should create NVM's working directory if it doesn't exist: mkdir ~/.nvm Add the following to ~/.zshrc or your desired shell configuration file: export NVM_DIR="$HOME/.nvm" [ -s "/opt/homebrew/opt/nvm/nvm.sh" ] && . "/opt/homebrew/opt/nvm/nvm.sh" # This loads nvm [  -s "/opt/homebrew/opt/nvm/etc/bash_completion.d/nvm" ] && . "/opt/homebrew/opt/nvm/etc/bash_completion.d/nvm" # This loads nvm bash_completion You can set $NVM_DIR to any location, but leaving it unchanged from /usr/local/opt/nvm will destroy any nvm-installed Node installations upon upgrade/reinstall. Type `nvm help` for further information. Bash completion has been installed to: / usr/local/etc/bash_completion. D = = > the Summary 🍺 / usr/local/Cellar/NVM / 0.35.3:7 files, 150.0 KB, built in 2 secondsCopy the code
  • After installation, Brew will prompt you to create the.nvm directory
% mkdir ~/.nvm
Copy the code
  • Edit the ~/.zshrc configuration file
% vi ~/.zshrc
Copy the code
  • Add the following to the ~/.zshrc configuration file
export NVM_DIR="$HOME/.nvm" [ -s "/opt/homebrew/opt/nvm/nvm.sh" ] && . "/opt/homebrew/opt/nvm/nvm.sh" # This loads nvm [  -s "/opt/homebrew/opt/nvm/etc/bash_completion.d/nvm" ] && . "/opt/homebrew/opt/nvm/etc/bash_completion.d/nvm" # This loads nvm bash_completionCopy the code

:wq Save the configuration and exit. Run the source command to make the configuration take effect

% source ~/.zshrc
Copy the code

Check whether the configuration takes effect

% echo $NVM_DIR
/Users/your-username/.nvm
Copy the code

See the help

% nvm -helpNote: to remove, delete, or uninstall nVM-just remove the '$NVM_DIR' folder (usually '~/.nvm') Note: to remove, delete, or uninstall nVm-just remove the '$NVM_DIR' folder (usually '~/.nvm')Copy the code

$NVM_DIR (~/.nvm); $NVM_DIR (~/.nvm

Note: The NVM installation process is much the same, except that the path must be correctly configured in the final configuration phase to ensure that your NVM commands are usable.

If you found this tutorial helpful, please like it!