Closure Compiler: JSC_PARSE_ERROR: Parse error

3.4k views Asked by At

Does anyone know how to fix the following error when trying to use Google's Closure Compiler:

JSC_PARSE_ERROR: Parse error.  primary expression expected at line 1 character 1 in www.myWebsite.co.uk
<!DOCTYPE HTML>
 ^

If i just specify javascript files i get the following error (errors appear for each file when i do one at a time):

JSC_PARSE_ERROR: Parse error. primary expression expected at line 17 character 72

http://www.myWebsite.co.uk/javascripts/tinynav.min.js

That files code is as follows:

    /*! http://tinynav.viljamis.com v1.1 by @viljamis */
(function(a,i,g){a.fn.tinyNav=function(j){var b=a.extend({active:"selected",header:"",label:""},j);return this.each(function(){g++;var h=a(this),d="tinynav"+g,f=".l_"+d,e=a("<select/>").attr("id",d).addClass("tinynav "+d);if(h.is("ul,ol")){""!==b.header&&e.append(a("<option/>").text(b.header));var c="";h.addClass("l_"+d).find("a").each(function(){c+='<option value="'+a(this).attr("href")+'">';var b;for(b=0;b<a(this).parents("ul, ol").length-1;b++)c+="- ";c+=a(this).text()+"</option>"});e.append(c);
b.header||e.find(":eq("+a(f+" li").index(a(f+" li."+b.active))+")").attr("selected",!0);e.change(function(){i.location.href=a(this).val()});a(f).after(e);b.label&&e.before(a("<label/>").attr("for",d).addClass("tinynav_label "+d+"_label").append(b.label))}})}})(jQuery,this,0);

I don't understand where the error is?

2

There are 2 answers

0
rds On

The closure compiler compiles closure-annontated JavaScript ; not random JavaScript.

0
ChrisAdmin On

As in the comments, CC is seeing a webpage. That webpage is the Git page, not the actual extern URL required in the CC header.

To Fix:

When at Github looking for your extern file: https://github.com/google/closure-compiler/blob/master/contrib/externs/jquery-1.12_and_2.2.js

Click the button called Raw to see the actual file URL: https://raw.githubusercontent.com/google/closure-compiler/master/contrib/externs/jquery-1.12_and_2.2.js

Then copy it in to your CC header

// @externs_url https://raw.githubusercontent.com/google/closure-compiler/master/contrib/externs/jquery-1.12_and_2.2.js