Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

'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"
  }
}
like image 234
Megha Avatar asked Dec 12 '22 05:12

Megha


2 Answers

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.

like image 122
Jack Avatar answered Dec 19 '22 05:12

Jack


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.

like image 34
Megha Avatar answered Dec 19 '22 06:12

Megha