Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Development Tools

Gruntfile.js won't run

I am trying to follow the grunt tutorial and implement it into one of my projects. The following code is the code from my gruntfile.js

module.exports = function(grunt) {

    grunt.initConfig({
        pkg: grunt.file.readJSON('package.json'),
        uglify: {
            build: {
                src:  'src/js/*.js',
                dest: 'js/appJS/timesInfinityJS/timesInfinity.min.js'
            }
        }
    });

    grunt.loadNPMTasks('grunt-contrib-uglify');


    grunt.registerTask('default', ['uglify:build']);

};

When I try and run the grunt command in terminal I receive the following error:

Loading "gruntfile.js" tasks...ERROR

TypeError: undefined is not a function Warning: Task "default" not found. Use --force to continue.

Aborted due to warnings.

I have been searching on Google and staring at this for a few hours now with no luck.

1 Answer

After a few days I finally figured out why this wouldn't run. Where it says grunt.loadNpmTasks(); I had capitalized every letter in npm. So not NPM but Npm is the correct syntax. I compared my file to the instructors again and again and my eyes just wouldn't see that.