Megha
Megha

Reputation: 1581

'module' is undefined in grunt javascript

I want to integrate Grunt on my java Script project. I have installed npm, grunt and all.

I have created the package.json file and GRUNTFILE.js for the grunt.

but when i run the "grunt" command i am getting this error 'module' is undefined.

GRUNTFILE.js

module.exports = function(grunt) {

  grunt.initConfig({
        pkg: grunt.file.readJSON('package.json')
    });

    grunt.registerTask('default', []);



};

Package.json

{
  "name": "Example",
  "version": "0.0.1",
  "private": true,
  "devDependencies": {
    "grunt": "latest",
    "grunt-cli": "^0.1.13"
  }
}

Upvotes: 4

Views: 5457

Answers (2)

Jack
Jack

Reputation: 3057

I also had this problem I found that making sure you have correctly named the grunt file to Gruntfile.js fixed my problem, silly but can be overlooked.

Upvotes: 11

Megha
Megha

Reputation: 1581

After running following command I am successfully run the grunt on my project.

  1. npm uninstall

  2. npm install -g grunt-cli (which install globally)

  3. npm install (On a Project directory)

Before running the third commend project must contain 'packge.json' and gruntfile.js files.

Upvotes: 2

Related Questions