3

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

Janith Widarshana
  • 3,213
  • 9
  • 51
  • 73
  • Check if jQuery is includes before you do these statements. This sais that jQuery has not been included yet. – Roboroads Sep 03 '15 at 07:44
  • @Robbin'Roboroads'Schepers Please see my edited question, Jquery.js file loaded correctly. – Janith Widarshana Sep 03 '15 at 07:49
  • Could still be the case, i can see you run javascript before the jquery include. What happens if you place the jquery include tag directly under the `` tag? – Roboroads Sep 03 '15 at 07:53
  • @Robbin'Roboroads'Schepers this issue is not related to jquery loading order as I feel. Jquery functions are working on browser properly even in current implementation. But when I run grunt build command above errors are displaying and it breaks the minify js file creation of MEAN JS application. – Janith Widarshana Sep 03 '15 at 08:15

1 Answers1

1

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.

pgrodrigues
  • 2,083
  • 1
  • 24
  • 28
  • It works for me.But even if all these warnings are fixed still public/dist/application.min.js do not build. I used grunt --force build. But my console still displaying backend Nodejs warnings. – Janith Widarshana Sep 04 '15 at 03:27
  • 1
    That's odd. You have to carefully check your gruntfile looking for file paths that you might have changed and forgot to update. – pgrodrigues Sep 04 '15 at 10:00