How to install Grunt on Mac using Node NPM

How to Mac

In this tutorial we will learn to install Grunt The JavaScript Task Runner on Mac using Node NPM.

If you already have Node and NPM installed on your Mac then you can jump directly to Step 3: Install Grunt.

Step 1: Install Homebrew

Homebrew is a package manager for Mac and makes installing and uninstalling packages on Mac easier. So, we will install Homebrew.

Use the following command to install homebrew on your Mac.

$ /usr/bin/ruby -e "$(curl -fsSL"

For more detail on Homebrew check their website.

Once we have Homebrew installed we can now install Node.

Step 2: Install Node

NodeJS and NPM which is a package manager for Node comes together. So, when we install Node via Homebrew we also get NPM.

To install Node on your Mac using Homebrew type the following command.

$ brew install node

Now check the Node version by typing the following command in the terminal.

$ node -v

And, check the version of NPM type the following command in the terminal.

$ npm -v

Click here to read the tutorial on How to install NodeJS on Mac.

Step 3: Install Grunt

Before installing Grunt make sure your NPM is up-to-date. Use the following command in the terminal to update NPM.

$ sudo npm update -g npm

This will update NPM globally on your system. Note! You may need sudo if you don't have permissions.

Now we will install Grunt. Use the following command in the terminal to install Grunt globally.

$ npm install -g grunt-cli

This will put the grunt in the system path and we will be able to use it from any directory.


YUSUF-MacBook-Pro:~ yusufshakeel$ npm install -g grunt-cli
/usr/local/bin/grunt -> /usr/local/lib/node_modules/grunt-cli/bin/grunt
└─┬ grunt-cli@1.2.0 
  ├─┬ findup-sync@0.3.0 
  │ └─┬ glob@5.0.15 
  │   ├─┬ inflight@1.0.6 
  │   │ ├── once@1.4.0  deduped
  │   │ └── wrappy@1.0.2 
  │   ├── inherits@2.0.3 
  │   ├─┬ minimatch@3.0.3 
  │   │ └─┬ brace-expansion@1.1.6 
  │   │   ├── balanced-match@0.4.2 
  │   │   └── concat-map@0.0.1 
  │   ├─┬ once@1.4.0 
  │   │ └── wrappy@1.0.2  deduped
  │   └── path-is-absolute@1.0.1 
  ├── grunt-known-options@1.1.0 
  ├─┬ nopt@3.0.6 
  │ └── abbrev@1.1.0 
  └── resolve@1.1.7 

YUSUF-MacBook-Pro:~ yusufshakeel$

Looking at the above output we can see that Grunt CLI v1.2.0 was installed.

Uninstall Grunt

To uninstall Grunt globally from your Mac use the following command in terminal.

$ npm uninstall -g grunt-cli

Note! You may need sudo if you don't have permissions.


YUSUF-MacBook-Pro:~ yusufshakeel$ npm uninstall -g grunt-cli
- abbrev@1.1.0 node_modules/grunt-cli/node_modules/abbrev
- balanced-match@0.4.2 node_modules/grunt-cli/node_modules/balanced-match
- concat-map@0.0.1 node_modules/grunt-cli/node_modules/concat-map
- brace-expansion@1.1.6 node_modules/grunt-cli/node_modules/brace-expansion
- inherits@2.0.3 node_modules/grunt-cli/node_modules/inherits
- minimatch@3.0.3 node_modules/grunt-cli/node_modules/minimatch
- path-is-absolute@1.0.1 node_modules/grunt-cli/node_modules/path-is-absolute
- wrappy@1.0.2 node_modules/grunt-cli/node_modules/wrappy
- once@1.4.0 node_modules/grunt-cli/node_modules/once
- inflight@1.0.6 node_modules/grunt-cli/node_modules/inflight
- glob@5.0.15 node_modules/grunt-cli/node_modules/glob
- findup-sync@0.3.0 node_modules/grunt-cli/node_modules/findup-sync
- grunt-known-options@1.1.0 node_modules/grunt-cli/node_modules/grunt-known-options
- nopt@3.0.6 node_modules/grunt-cli/node_modules/nopt
- resolve@1.1.7 node_modules/grunt-cli/node_modules/resolve
- grunt-cli@1.2.0 node_modules/grunt-cli
YUSUF-MacBook-Pro:~ yusufshakeel$

That's all for this tutorial. Have fun coding.