如何findJS_Parse_Error的来源?

我正在运行一个快速应用程序,我得到一个JS_Parse_Error。 我无法弄清楚为什么。 我已经基本评论了我写的所有新代码,但我仍然得到错误。 有没有办法找出哪些Javascript行给我的错误?

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) 

这可能与您无关,但我得到了同样的错误信息 – 哪一个不是很详细,我不得不说 – 而我的问题是一个逗号缺失。

注意在ng-show之前缺less的逗号…

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

我有一个键/值对的数组相同的问题。

我的代码看起来像这样:

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

显然, 你不能在你的键中使用连字符而不用引号括住键

所以,要解决这个问题,你也可以做

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

要么

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

就我而言,这是一对花括号,需要删除:

 AlertService.success(alertKey, param1 ); 

代替

 AlertService.success(alertKey, { param1 }); 

太糟糕了,uglify-js有时并不指出你的问题在哪里…

另一个可能是一个问题(我的情况是什么问题)是正则expression式。 确保你创build正则expression式像这个新的RegExp(“/ [^] + / g”)而不是/ [^] + / g

也使用var而不是let。

希望这有助于某人,

uglify-js 1.2.6版本

在我的情况下,下面的代码是造成这个问题

 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); } ); 

为了确切地指出,uglify不能parsing"=>"

当我试图使用对象的简写符号时,出现这个错误。