Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
15
rated 0 times [  20] [ 5]  / answers: 1 / hits: 16656  / 9 Years ago, mon, may 11, 2015, 12:00:00

I'm new to the Grunt world.


After installing grunt-cli, and all the dependencies, here is my : Gruntfile.js


/*
Grunt installation:
-------------------
npm install -g grunt-cli
npm install -g grunt-init
npm init (creates a `package.json` file)

Project Dependencies:
---------------------
npm install grunt --save-dev
npm install grunt-contrib-concat --save-dev
npm install grunt-contrib-watch --save-dev



Example Usage:
--------------
grunt -v
grunt release -v

*/


module.exports = function(grunt) {
"use strict";

grunt.initConfig({

concat: {

js: {
src: ['js/bootstrap.min.js', 'js/jquery-1.10.2.min.js'],
dest: 'build/js/scripts.js'
},

css: {
src: ['css/bootstrap.min.css', 'css/font-awesome.min.css'],
dest: 'build/css/styles.css'
}
},

watch: {

js: {
files: ['js/**/*.js'],
task: ['concat:js']
},

css: {
files: ['css/**/*.css'],
task: ['concat:css']
}
}

});

grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasksNpmTasks('grunt-contrib-watch');
grunt.registerTask('default', ['concat', 'watch']);

};



Result


Now the testing part, I tried run grunt, I kept getting :


Loading "Gruntfile.js" tasks...ERROR
>> TypeError: undefined is not a function
Warning: Task "default" not found. Use --force to continue.

Aborted due to warnings.



Can someone please tell me what did I do wrong here ?


More From » gruntjs

 Answers
8

It looks like the default target is not being created properly due to a typo. Try renaming



grunt.loadNpmTasksNpmTasks('grunt-contrib-watch');


to



grunt.loadNpmTasks('grunt-contrib-watch');

[#66644] Friday, May 8, 2015, 9 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
ramseydeshaunc

Total Points: 30
Total Questions: 91
Total Answers: 103

Location: Palau
Member since Tue, May 30, 2023
1 Year ago
;