Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to resolve "module is not defined."

Tags:

jshint

I have a module that I'm using elsewhere, but I keep getting "module is not defined." It works if I use the global directive but that implies that the module is defined elsewhere. Is there any way to fix this issue? Thank you

In module.js

/* exported module */
var module = (function($){
   ...
   return {method: method};
})($);
$(module.method);

In foo.js

var foo = function() {
     function bar() {
         module.method();
     }
};
$(foo);
like image 290
petabyte Avatar asked Jul 10 '14 15:07

petabyte


2 Answers

In my case didn't work, thus, I injected next piece of code:

/* globals module: false */
like image 151
lesyk Avatar answered Oct 29 '22 17:10

lesyk


You can also do the following in your jshint.rc

 "jshint_options":
    {
        "globals": {
            "module": false
        }
     }
like image 40
Nikos Avatar answered Oct 29 '22 17:10

Nikos