Questions And Answers

More Tutorials

NodeJS grunt

Grunt is a JavaScript Task Runner, used for automation of repetitive tasks like minification, compilation, unit testing, linting, etc.

In order to get started, you'll want to install Grunt's command line interface (CLI) globally.

npm install -g grunt-cli

Preparing a new Grunt project: A typical setup will involve adding two files to your project: package.json and the Gruntfile.
package.json: This file is used by npm to store metadata for projects published as npm modules. You will list grunt and the Grunt plugins your project needs as devDependencies in this file.

Gruntfile: This file is named Gruntfile.js and is used to configure or define tasks and load Grunt plugins.

Example package.json:
 "name": "my-project-name",
 "version": "0.1.0",
 "devDependencies": {
 "grunt": "~0.4.5",
 "grunt-contrib-jshint": "~0.10.0",
 "grunt-contrib-nodeunit": "~0.4.1",
 "grunt-contrib-uglify": "~0.5.0"

Example gruntfile:

module.exports = function(grunt) {
 // Project configuration.
 pkg: grunt.file.readJSON('package.json'),
 uglify: {
 options: {
 banner: '/*! <%= %> <%="yyyy-mm-dd") %> */\n'
 build: {
 src: 'src/<%= %>.js',
 dest: 'build/<%= %>.min.js'
 // Load the plugin that provides the "uglify" task.
 // Default task(s).
 grunt.registerTask('default', ['uglify']);


In this page (written and validated by ) you learned about NodeJS grunt . What's Next? If you are interested in completing NodeJS tutorial, your next topic will be learning about: NodeJS Using WebSockets.

Incorrect info or code snippet? We take very seriously the accuracy of the information provided on our website. We also make sure to test all snippets and examples provided for each section. If you find any incorrect information, please send us an email about the issue:

Share On:

Mockstacks was launched to help beginners learn programming languages; the site is optimized with no Ads as, Ads might slow down the performance. We also don't track any personal information; we also don't collect any kind of data unless the user provided us a corrected information. Almost all examples have been tested. Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness of all content. By using, you agree to have read and accepted our terms of use, cookies and privacy policy.