Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Grunt is not defined

Tags:

gruntjs

Just Getting started with grunt, and when I run grunt I get this error

Loading "Gruntfile.js" tasks...ERROR
>> ReferenceError: grunt is not defined

This is my Gruntfile.js

module.exports = function(grunt){
  'use strict';
};
like image 672
Dan Baker Avatar asked May 31 '13 05:05

Dan Baker


People also ask

Is grunt deprecated?

grunt. util. _ is deprecated and we highly encourage you to npm install lodash and var _ = require('lodash') to use lodash .

What is grunt JS used for?

Grunt is a JavaScript task runner, a tool used to automatically perform frequent tasks such as minification, compilation, unit testing, and linting. It uses a command-line interface to run custom tasks defined in a file (known as a Gruntfile). Grunt was created by Ben Alman and is written in Node.

What is grunt config?

config. Access project-specific configuration data defined in the Gruntfile . Note that any method marked with a ☃ (unicode snowman) is also available directly on the grunt object, and any method marked with a ☆ (white star) is also available inside tasks on the this object.


1 Answers

I had it suddenly happen to me,

'use strict';
module.exports = function(grunt) {
  grunt.initConfig({
    sass: {
      dist: {
        files: {
          'style.css': 'style.scss'
        },
        options: {
          includePaths: ['css/'],
          outputStyle: 'nested'
        }
      }
    },
  });
  grunt.loadNpmTasks('grunt-sass');
  grunt.registerTask('sass', ['sass']);

};

Make sure the loadNpmTasks and registerTask commands are inside the module.export, if they're outside of the scope of that closure grunt won't be defined, so it fails

like image 115
Dvid Silva Avatar answered Sep 28 '22 03:09

Dvid Silva