Search code examples
jquerygruntjsmeanjs

Meanjs grunt build jquery $ is not defined


I have developed a somewhat large meanjs application and when I run grunt build it gives me Jquery issue as following.

enter image description here

I used Jquery self invoking methods too as follows. But it also give me error.

(function ($){
    $('#renew').modal('hide');
})(jQuery);

enter image description here

Because of these issue 'public/dist/application.min.js' is not creating.

I can see jquery has loaded to the browser as follows.

enter image description here


Solution

  • I don't think that is an error. In fact I believe it is a warning that jshint is giving because you are using 'use strict'; and it doesn't know that $ was defined (in jquery file).

    You can just add $ to the globals in your .jshintrc file like this:

    {
        "globals" : {
            "$": false
        }
    }
    

    Or add the following line to all the js files that use $

    /*global $:false */
    

    As a side note, you should also be able to make it build even with the warnings by using grunt --force but still you should fix it as explained above.