Table of Contents
Was this article helpful?
Try Vultr Today with

$50 Free on Us!

Want to contribute?

You could earn up to $600 by adding new articles.

How to Install GruntJS on Debian 9

Last Updated: Fri, Jan 11, 2019
Debian Linux Guides Node.js Programming
Archived content

This article is outdated and may not work correctly for current operating systems or software.

GruntJS is a JavaScript task runner written on top of NodeJS. It can be used to automate repetitive tasks for your application like minification, compilation, unit testing, linting and more; with minimum effort.


Before you begin, you should have a non-root user account with sudo privileges set up on your system.


Refresh your local package index:

sudo apt-get update

Install curl:

sudo apt-get install curl

Add the package repository of NodeJS 8.x with the following command:

curl -sL | sudo -E bash -

Next, we need to install NodeJS and NPM all together along with the development tools:

sudo apt-get install build-essential nodejs

Now check to ensure NodeJS and NPM are working:

node --version && npm --version



Install Grunt:

sudo npm install -g grunt-cli

This will install Grunt globally on your system. Run the following command to check the version installed on your system:

grunt --version

#grunt-cli v1.2.0

Install Grunt on a new project

To install grunt on a new project we will need to add two files to your project directory: package.json and Gruntfile.js.

  • package.json: This file is used by NPM to store meta-data for projects published as NPM modules.

  • Gruntfile.js: This file is` and is used to configure or define tasks, as well as to load Grunt plugins.

Navigate to the root directory of your package:

cd /path/to/project

Run the following command to create a package.json file:

sudo npm init

Answer the questions in the command line questionnaire.

Once your package.json file is created, install Grunt as a development dependency:

sudo npm install grunt --save-dev

Create the Gruntfile.js file:

nano Gruntfile.js

Register a simple default task:

var grunt = require('grunt');

grunt.registerTask('default', 'default task description', function(){

  console.log('hello world');


Now, run the default task:


That concludes our tutorial, thank you for reading.

Want to contribute?

You could earn up to $600 by adding new articles.