Home > Back-end >  Global not defined when running a JS script in a Java application
Global not defined when running a JS script in a Java application

Time:08-01

I have a js script which I want to execute in my Java application.

I have tried to use the Chromedriver API to do this

But it throws the following exception:

global not defined

I am so confused because the script can simply run with node xx.js

Does this mean the js which uses the global object cannot execute in a Java application?

CodePudding user response:

According to MDN, global is Node-specific, so you can't expect to be able to use it if you're not running under Node. They suggest globalThis as the portable replacement.

  •  Tags:  
  • java
  • Related