Mac 开发配置学习手册

Node.js

Install Node.js with Homebrew:

$ brew update
$ brew install node

Node modules are installed locally in the node_modules folder of each project by default, but there are at least two that are worth installing globally. Those are CoffeeScript and Grunt:

$ npm install -g coffee-script
$ npm install -g grunt-cli

Npm usage

To install a package:

$ npm install <package> # Install locally
$ npm install -g <package> # Install globally

To install a package and save it in your project's package.json file:

$ npm install <package> --save

To see what's installed:

$ npm list # Local
$ npm list -g # Global

To find outdated packages (locally or globally):

$ npm outdated [-g]

To upgrade all or a particular package:

$ npm update [<package>]

To uninstall a package:

$ npm uninstall <package>