This article describes how to install a node and npm on the mac OS X system.
Homebrew: For details, please click on the official website to know
First, check whether the installation Homebrew
Through the brew -v can see if installation homebrew, homebrew version number is displayed if the correct instructions homebrew already installed, if not.
Second, the installation:
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Uninstall:
$ cd`brew --prefix`
$ rm -rf Cellar
$ brew prune
$ rm`git ls-files`
$ rm -r Library/Homebrew Library/Aliases Library/Formula Library/Contributions
$ rm -rf .git$ rm -rf ~/Library/Caches/Homebre
Three, Homebrew basic use
Install any package
$ brew install <packageName>
Example: Installation node
$ brew install node
Uninstall any package
$ brew uninstall <packageName>
Example: Uninstall npm
$ brew uninstall npm
Query packages available
$ brew search <packageName>
View the list of installed packages
$ brew list
View any package information
$ brew info <packageName>
Homebrew Update
$ brew update
View Homebrew version
$ Brew -v
Homebrew Help
$ brew -h
Fourth, pay attention
After Mac OS X 10.11 system, read and write files in / usr / local / etc directory system is the system needs root privileges, previous Homebrew installed If you do not specify the installation path, installed by default in the root user read and write permissions on these systems need directory, resulting in the need to add some command sudo prefix to perform, such as upgrade Homebrew need:
$ sudo brew update
If you do not want to use the sudo command every time, you have two ways to choose:
For the / usr file read and write in the local directory / users authorized to carry out root
$ sudo chown -R$USER/usr/local
Example:
$ sudo chown -R LeeMac /usr/local