Debug dynamically loaded JavaScript code with IntelliJ and the Nashorn engine

后端 未结 1 1817
清歌不尽
清歌不尽 2021-01-14 01:48

I am dynamically loading and running JavaScript code that is stored on disk in a YAML file. I would like to know if it is possible (using intelliJ) to debug the JS code even

1条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-14 02:37

    Based on this blog post https://blogs.oracle.com/sundararajan/remote-debugging-of-nashorn-scripts-with-netbeans-ide-using-debugger-statements, you can just attach a remote java debugger to process.

    You can do this in IntelliJ IDEA by creating a new remote run configuration.

    After attaching, use the JavaScript command:

    debugger;
    

    This will force the debugger to break if it is attached. You can then inspect the values of variables within the variable window.

    If you can't manage to attach IntelliJ, open the browsers inspector/debugger and this same line of javascript will cause the browser's debugger to break on that line.

    0 讨论(0)
提交回复
热议问题