How to install Grunt.js – The Javascript task runner

Grunt.js has dependency on Node.js. Before we install the Grunt, we need to install the Node.js.

Installing the Grunt.js involves the following steps.

  1. Install latest version of Node.js from below link

Website : https://nodejs.org/en/

NodeJS

2. Install grunt-cli globallly. using -g. That means we don’t need to install every time whenever we want it across our computer.

grunt-1

npm install grunt-cli -g

3. Create a package.json file using npm-init as show below:

grunt-2

npm init

What is package.json ?

All npm packages contain a file, usually in the project root, called package.json – this file holds various metadata relevant to the project. This file is used to give information to npm that allows it to identify the project as well as handle the project’s dependencies.

4. Install grunt locally

install-grunt-locally

npm install grunt --save-dev

This will add grunt to the package.json as follows:

install-grunt-locally-2

5. Creating the Gruntfile.js by right click and create a new file in the Project folder

grunt-3

6. Install plug-ins

We will install all the plug-ins and configure grunt-js in gruntFile.js. We will explain this in next article.

 

Join Discussion

This site uses Akismet to reduce spam. Learn how your comment data is processed.