Rotating display on Intel NUC?

Yeah, xrandr communicates with the running X process, so I don’t think it will behave correctly (or maybe not function at all?) if X is not running. That would explain why it can’t open the display in your script – the display just isn’t there yet.

If you move those lines to after your startx command they should work. You might want to add a sleep in there just to give X time to start up before you do it, e.g.

# Start application
startx /usr/src/app/node_modules/electron/dist/electron /usr/src/app --enable-logging
# Wait for X to come up
sleep 3
# Rotate display and touchscreen
xrandr -o right
xinput set-prop "ELAN Touchscreen" --type=float "Coordinate Transformation Matrix" 0 1 0 -1 0 1 0 0 1

You can also configure a bunch of this stuff in a file that will be loaded when X starts so you don’t have the delay there in xorg.conf: https://wiki.archlinux.org/index.php/xorg#Configuration