最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to find source of JS_Parse_Error? - Stack Overflow

programmeradmin8浏览0评论

I am running an Express app, and I am getting a JS_Parse_Error. I cannot figure out why. I have basically mented 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)

I am running an Express app, and I am getting a JS_Parse_Error. I cannot figure out why. I have basically mented 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)
Share Improve this question edited Jul 30, 2013 at 16:00 egidra asked Jul 30, 2013 at 15:46 egidraegidra 9,08721 gold badges67 silver badges92 bronze badges 3
  • 1 Can you post the relevant code along with the stack trace? – Willem Ellis Commented Jul 30, 2013 at 15:48
  • The problem is that I'm not sure what the relevant code is. I have 5 Javascript files. Even when I delete all of them, I still get the error. IS there a way to pinpoint what file is giving me the error? – egidra Commented Jul 30, 2013 at 16:01
  • I'm pretty sure there's more information on the JS_Parse_Error about the reason. Can you get that? – Bergi Commented Jul 30, 2013 at 16:38
Add a ment  | 

6 Answers 6

Reset to default 4

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 ma missing.

Notice the ma missing before ng-show...

.container(itemscope, itemtype='http://schema/Person' ng-show='user')
   .row

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

My code looked like this:

- var links = {stack-overflow: "//stackoverflow./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./users/2479481/"}

or

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

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

In my case, it was a pair of curly braces that needed to be removed:

AlertService.success(alertKey,
    param1
);

Instead of

AlertService.success(alertKey, {
    param1
});

Too bad that uglify-js sometimes doesn't point you to where the issue is...

In my case following code was causing the issue

loc8rData.locationByCoords(lat, lng)
    .then(
        response => {
            vm.message = response.data.length > 0 ? "" : "No locations found";
            vm.data = { locations: response.data };
        },
        e => {
            vm.message = "Sorry, something's gone wrong ";
            console.log(e);
        }
    );

To exactly pin point, uglify could not parse "=>".

I was getting this error when I tried to use the object short hand notation.

发布评论

评论列表(0)

  1. 暂无评论