tecadmin.net /install-nvm-macos-with-homebrew/

How To Install NVM on macOS with Homebrew

3-3 minutes 2020/11/24

The NVM (Node Version Manager) is a shell script used for installing and managing Node.js on a Linux based system. The macOS users can install NVM using the homebrew.

This tutorial help you to install NVM on your macOS system and manage Node.js versions.

Prerequisites

You must have macOS desktop access with administrator privileges.

Login to the macOS desktop system and install Homebrew on your system (if not already installed)

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" 

For more instruction visit Homebrew installation tutorial.

Step 1 – Remove existing Node Versions

If your system already have node installed, uninstall it first. My system already have installed node via Homebrew. So uninstalling it first. Skip if not already installed.

brew uninstall --ignore-dependencies node 
brew uninstall --force node 

Now, you system is ready for the installation. Update the Homebrew package list and install NVM.

brew update 
brew install nvm 

Next, create a directory for NVM in home.

mkdir ~/.nvm 

Now, configure the required environment variables. Edit the following configuration file in your home directory

vim ~/.bash_profile 

and, add below lines to ~/.bash_profile ( or ~/.zshrc for macOS Catalina or later)

export NVM_DIR=~/.nvm
source $(brew --prefix nvm)/nvm.sh

Press ESC + :wq to save and close your file.

Next, load the variable to the current shell environment. From the next login, it will automatically loaded.

source ~/.bash_profile

That’s it. The NVM has been installed on your macOS system. Go to next step to install Node.js versions with the help of nvm.

Step 3 – Install Node.js with NVM

First of all, see what Node versions are available to install. To see available versions, type:

nvm ls-remote 

Now, you can install any version listed in above output. You can also use aliases names like node for latest version, lts for latest LTS version, etc.

nvm install node     ## Installing Latest version 
nvm install 14       ## Installing Node.js 14.X version 

After installing you can verify what is installed with:

nvm ls 

nvm list node.js macos

If you have installed multiple versions on your system, you can set any version as the default version any time. To set the node 14.X as default version, simply use:

nvm use 14 

Similarly, you can install other versions like Node 12.X or Node 15 and switch between them.

Conclusion

This tutorial explained you to how to install NVM and node.js on macOS system.

::...
免责声明:
当前网页内容, 由 大妈 ZoomQuiet 使用工具: ScrapBook :: Firefox Extension 人工从互联网中收集并分享;
内容版权归原作者所有;
本人对内容的有效性/合法性不承担任何强制性责任.
若有不妥, 欢迎评注提醒:

或是邮件反馈可也:
askdama[AT]googlegroups.com


订阅 substack 体验古早写作:


点击注册~> 获得 100$ 体验券: DigitalOcean Referral Badge

关注公众号, 持续获得相关各种嗯哼:
zoomquiet


自怼圈/年度番新

DU22.4
关于 ~ DebugUself with DAMA ;-)
粤ICP备18025058号-1
公安备案号: 44049002000656 ...::