Brew mode
If the machine does not have node installed, then the brew install nvm
NVM is installed first.
Next you need to add the following in the shell's configuration file (~/.BASHRC, ~/.profile, or ~/.ZSHRC):
# for Nvmexport Nvm_dir=~/.nvmsource $ (Brew--prefix NVM)/nvm.sh
Note The order of the configuration in case the new terminal is opened and node cannot be found.
Restart the terminal, the command line can use NVM, using the nvm install <version>
corresponding node version of the installation, when writing this article, I am using nvm install 0.10
, the installation version is v0.10.32. Use nvm use <version>
, and then nvm alias default <version>
make sure that there is a default version. Last use nvm ls
view.
Brew Method Supplement
If you previously installed node through ' Brew Install node ', you need to delete the node that exists on the system first:
Brew Remove--force nodesudo rm-r/usr/local/lib/node_modulesbrew prunesudo rm-r/usr/local/include/node# Check if brew is normal bre W Doctor
Use Brew to install NVM on Mac to support multiple versions of Nodejs