Program can't connect to X server when started by node-red

I stumped here, I've a shell script that starts my pythonAI. It works fine on Raspberry Pi Stretch when launched by a node-red exec node. But when launhed on Ubuntu 18.04 node red it dies with ": cannot connect to X server" in my log file. If I run the script from a terminal on the Ubuntu machine it works as expected. If I launch it from my desktop (where the node-red webpage is being viewed/edited) via ssh -X it works. I get the X display locally when launched from the 18.04 terminal and I get the the X display on my desktop when launched with ssh -X.

Why does running the script via node-red exec node not work the same as launching it via a terminal login?

Does this script run a GUI application? If so, I'd suspect that running it from a background server does not have a Display to work with. If that's missing, you may be able to add a line to the script that sets the env variable for specifying which display to use...

How exactly do you launch the script, what commands?

Hi,
Not Ubuntu but I have Debian installed on a laptop and NR launches a Python script and it works fine. I use this command in the exec node:

export DISPLAY=:0 && uxterm -geometry 96x24-400+200 -e /usr/bin/python /home/pi/dnn_pq_analyzer.py

Basically my script only uses the X display when running in a debug/setup mode, I'd forgotten that I'd changed the default to be that mode while making a "unified" version that runs on Windows and Linux. For my purposes it doesn't really make sense to start in the debug/setup mode from node-red since it is ultimately intended to run "headless", so I changed my start up script to invoke it with my parameter to suppress the display. This should prevent re-occurrence on other systems irrespective if I forget to reset the default or not.

krambriw's solution will be filed away should I ever have the need to start an X app from node-red, although actually all I needed to do was add:

export DISPLAY=:0

To my script before executing the command and then the debug/setup windows do popup when started from node-red.

Thanks!