1

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 ?

1
  • It doesn't understand grunt.loadNpmTasksNpmTasks. It should be grunt.loadNpmTasks like the previous one. I think it's just confused. Commented May 11, 2015 at 15:26

2 Answers 2

3

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');
Sign up to request clarification or add additional context in comments.

7 Comments

Any diff between them ?
The first isn't a valid grunt method.
Quick question, I seem to be halting say Running Watch task Waiting ...
grunt-contrib-watch is meant to do that, it's saying that the program is waiting, listening (watching) for changes.
IS there a way to configure my grunt watch to do nothing if nothing has been change ?
|
1

Have faced similar issues and tried below command where your node modules is installed which resolved issue for me:

npm install --unsafe-perm

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.