Stephen Stephen - 18 days ago 5
jQuery Question

.net mvc Updated jquery now getting critical error

I updated jquery today through NuGet and I am now receiving the following error:

JavaScript critical error at line 1, column 11 http://localhost:53779/Scripts/jquery-1.9.0.min.map

SCRIPT1004: Expected ';'


Has anyone else come across this and can suggest a solution?

Answer

I stumbled on this by accident today and thought I should respond with an actual fix to this problem.

In my BundleConfig.cs I had the following:

bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
            "~/Scripts/jquery-1.*"));

The wildcard was being used to get the latest version of jQuery, however, the Bundle Builder was picking up the map file as well.

By updating the BundleConfig.cs as follows:

bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
            "~/Scripts/jquery-{version}.js"));

This solved the problem. The {version} token is a replacement that does a best match against the file. So now instead of all the files getting added you get a match on the library you are requesting for bundling and minification.

Source for this fix was found here http://jameschambers.com/2013/01/jquery-script-map-causing-critical-error-in-jquery-1-9-0/

Comments