Run NinjaRMM custom library script from console

I need to run javascript code on an ninjaRMM managed device.
I know how to do it using a powershell script,I have problems doing it with a javascript.

enter image description here

When this script is added to the ninjaRMM library and then run on a device, I get errors: syntax error:const; console.log:console is undefined

The above errors are signed with “Microsoft Script Host v5.81 which does support “const” keyword and I still can’t figure out what is in the global namespace on that engine.

Googling has been hopeless: all I can find is info on accessing the Ninja API from a node server.

  1. Add simple hello world as new script in library in ninja console Administration=>Scripts:

const msg = “Hello World!!”;
console.log(msg);

  1. Open device in the console=>Run=>from library=>my script
  2. Script returns with “success”
  3. clicking more in the status box yields:
    enter image description here

output:
Hello World!!