Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to find source of JS_Parse_Error?

I am running an Express app, and I am getting a JS_Parse_Error. I cannot figure out why. I have basically commented out all of the new code that I've written, yet I am still getting the error. Is there a way to find out what Javascript line is giving me the error?

Error
    at new JS_Parse_Error (/home/charlie/Projects/chat/node_modules/jade/node_modules/with/node_modules/uglify-js/lib/parse.js:196:18)
    at js_error (/home/charlie/Projects/chat/node_modules/jade/node_modules/with/node_modules/uglify-js/lib/parse.js:204:11)
    at croak (/home/charlie/Projects/chat/node_modules/jade/node_modules/with/node_modules/uglify-js/lib/parse.js:636:9)
    at token_error (/home/charlie/Projects/chat/node_modules/jade/node_modules/with/node_modules/uglify-js/lib/parse.js:644:9)
    at expect_token (/home/charlie/Projects/chat/node_modules/jade/node_modules/with/node_modules/uglify-js/lib/parse.js:657:9)
    at expect (/home/charlie/Projects/chat/node_modules/jade/node_modules/with/node_modules/uglify-js/lib/parse.js:660:36)
    at expr_atom (/home/charlie/Projects/chat/node_modules/jade/node_modules/with/node_modules/uglify-js/lib/parse.js:1112:17)
    at maybe_unary (/home/charlie/Projects/chat/node_modules/jade/node_modules/with/node_modules/uglify-js/lib/parse.js:1287:19)
    at expr_ops (/home/charlie/Projects/chat/node_modules/jade/node_modules/with/node_modules/uglify-js/lib/parse.js:1322:24)
    at maybe_conditional (/home/charlie/Projects/chat/node_modules/jade/node_modules/with/node_modules/uglify-js/lib/parse.js:1327:20)
like image 752
egidra Avatar asked Jul 30 '13 15:07

egidra


3 Answers

This might not be relevant for you anymore, but I got this same error message - Which is not so verbose I have to say - And my problem was a comma missing.

Notice the comma missing before ng-show...

.container(itemscope, itemtype='http://schema.org/Person' ng-show='user')
   .row
like image 99
jackdbernier Avatar answered Nov 09 '22 13:11

jackdbernier


I had the same problem with an array of key/value pairs.

My code looked like this:

- var links = {stack-overflow: "//stackoverflow.com/users/2479481/"}

Apparently, you can't use hyphens in your keys without wrapping the key in quotes.

So, to fix the problem, you can do either

- var links = {"stack-overflow": "//stackoverflow.com/users/2479481/"}

or

- var links = {stackoverflow: "//stackoverflow.com/users/2479481/"}
like image 36
Luke Willis Avatar answered Nov 09 '22 14:11

Luke Willis


Another thing that might be a problem (what was the problem in my case) are regular expressions. Make sure you create regex like this new RegExp("/[^ ]+/g") instead of /[^ ]+/g

Also use var instead of let.

Hope this helps someone,

uglify-js version 1.2.6

like image 1
Dushan Gajik Avatar answered Nov 09 '22 14:11

Dushan Gajik