Required steps:
- make sure you have installed below packages:
pango.x86_64 libXcomposite.x86_64 libXcursor.x86_64 libXdamage.x86_64 libXext.x86_64 libXi.x86_64 libXtst.x86_64 cups-libs.x86_64 libXScrnSaver.x86_64 libXrandr.x86_64 GConf2.x86_64 alsa-lib.x86_64 atk.x86_64 gtk3.x86_64 ipa-gothic-fonts xorg-x11-fonts-100dpi xorg-x11-fonts-75dpi xorg-x11-utils xorg-x11-fonts-cyrillic xorg-x11-fonts-Type1 xorg-x11-fonts-misc
use yum install to install above dependencies should be fine. And be careful your are 64 bit or 32 bit.
2. Install VNC server:
yum install tigervnc-server
and make sure you set your password through
vncpasswd
and know what to start/stop/kill vnc
systemctl start [email protected]:1.service systemctl stop [email protected]:1.service vncserver -kill :1
and your port should be 5901 (if you use 1.service)
3. use gnome-terminal:
export DISPLAY=:0 gnome-terminal --display=:0
4. in your js file, make sure your browser has below arguments:
const browser = await puppeteer.launch({args: ['--no-sandbox', '--disable-setuid-sandbox']});
Then your js file:
node index.js
6. If you need to use cronjob, you can try like this:
export DISPLAY=:0; node index.js