Monday, February 12, 2018

What to do if we are unable to build a JET app and getting unexpected token issue.

Sometimes when we try to build or deploy the JET application with the below two commands ..
a. ojet build --release
b. grunt build:release

..we get the below error stack.

node_modules\uglify-js\tools\node.js:27:1), <anonymous>
:86:23)
    at formatError (util.js:642:16)
    at formatValue (util.js:544:18)
    at inspect (util.js:324:10)
    at format (util.js:191:12)
    at Console.log (console.js:127:21)
    at tooling.build.then.catch.error (C:\Users\AppData\Roaming\npm\nod
e_modules\@oracle\ojet-cli\lib\tooling\build.js:29:27)
    at <anonymous>
  message: 'Unexpected token: name (binary)',
  filename: 0,
  line: 239,
  col: 22,
  pos: 11651 }

At the first glance we might not be able to decide if the error is from the
a. Our developed source code
b. node_modules libraries
c. or the files in the directory structure : C:\Users\AppData\Roaming\npm\nod
e_modules

However by doing the modifying the below function in the file : /node-modules/uglify-js/lib/parse.js ...


  1. function unexpected(token) {  
  2.   console.trace()  //  HERE THE DIAGNOSTIC CHANGE TO DETERMINE THE FAILURE  
  3.    if (token == null)  
  4.   token = S.token;  
  5.   token_error(token, "Unexpected token: " + token.type + " (" + token.value + ")");  
  6. };  

.. we can get hold of token that is causing the issue.

{ SyntaxError: Unexpected token: name (binary)
    at JS_Parse_Error.get (eval at <anonymous> (D:\node_modules\uglify-js\tools\node.js:27:1), <anonymous>
:86:23)

Here binary is the culprit and we can search this keyword in our entire application and fix the issue.

In my case I was using an expression like below.. where in let keyword was not being identified by the build tools.

let binary = '';

Thanks,
Srikanth

Courtesy : Oracle community thread

No comments:

Post a Comment

Fusion BIP : How to show one parameter in report and pass different value to the datamodel

Hi All, There can be a scenario where we might need to show one value in the report and a different value to the actual query. Lets say a...