SyntaxError: Unexpected token < in JSON at position 0 @ /work\jsreport\jsreport\node_modules\vm2\lib/contextify.js:89



  • hi,

    I have script binded to a report.
    and when I call that report it throws error.

    2020-10-15T07:34:28.377Z - debug: Executing script MyScript
    
    /work\jsreport\jsreport\node_modules\vm2\lib/contextify.js:89
                                            throw Decontextify.value(e);
                                            ^
    SyntaxError: Unexpected token < in JSON at position 0
        at JSON.parse (<anonymous>)
        at Proxy.result.on (evaluate-user-script.js:46:39)
        at Object.apply (/work\jsreport\jsreport\node_modules\vm2\lib/contextify.js:87:36)
        at emitNone (events.js:111:20)
        at IncomingMessage.emit (events.js:208:7)
        at endReadableNT (_stream_readable.js:1064:12)
        at _combinedTickCallback (internal/process/next_tick.js:138:11)
        at process._tickCallback (internal/process/next_tick.js:180:9)
    

    even the begining of the beforerender does not run.
    I don't see console log in first line.

    function beforeRender(req, res, done) {
        console.log("beforerender");
    

    I didn't changed anything in the environment.
    it was working for my previous calls.

    what can be the reason?

    where is the node_modules files in windows?

    how can I delete and re-install packages?



  • What if you remove the script content and keep just

    function beforeRender(req, res) {
    
    }
    

    Does it also crash?
    Don't you have some other scripts that are marked as global? Mabe it's crashing there.
    It seems like something in your scripts is calling JSON.parse() on an invalid json.

    where is the node_modules files in windows?

    typically in your application folder

    how can I delete and re-install packages?

    you can delete the node_modules and call npm i inside the app folder. (Be sure to backup everything)
    However, I would rather explore your scripts first.


Log in to reply
 

Looks like your connection to jsreport forum was lost, please wait while we try to reconnect.