Running NightmareJS on CentOS 6

Most posts on this site aren’t exactly riveting to read, but they might just save you hours and hours of work.  This one is no different!

NightmareJS is fantastic, but due to its reliance on Electron and a strange mix of dependencies, getting it to work on CentOS is very involved.  Lucky for you, I’ve compiled all of the necessary commands and even compiled binaries/libraries to save you from losing what’s left of your hair.

These instructions have been tested on CentOS 6.7.

Install Prerequisites

X-related Packages

Xvfb is required to provide the pseudo-headless-X environment; libXScrnSaver is required to add

[root@backend ~]$ yum install xorg-x11-server-Xvfb libXScrnSaver

MS fonts

(More info:

[root@backend ~]# yum install curl cabextract xorg-x11-font-utils fontconfig
 [root@backend ~]# rpm -i

Upgrade gcc library

I’ve already done the hard work for you and compiled gcc 6.3 from source on CentOS 6.8, 64 bit.  Download the library at  Extract it to the home directory of whichever user you’re logged in as (in my case, root).  Then, install it using the following instructions:

[root@backend ~]# cd /usr/lib64/
 [root@backend lib64]# mv ~/ .
 [root@backend lib64]# ls -alF*
 lrwxrwxrwx 1 root root 19 Oct 1 2015 ->*
 -rwxr-xr-x 1 root root 987096 Jul 22 2015*
 -rwxr-xr-x 1 root root 11508835 Apr 25 18:53*
 #Notice the symbolic link to 6.0.13
 [root@backend lib64]# rm
 [root@backend lib64]# ln -s
 [root@backend lib64]# ls -alF /usr/lib64/*
 lrwxrwxrwx 1 root root 19 Apr 26 18:34 /usr/lib64/ ->*
 -rwxr-xr-x 1 root root 987096 Jul 22 2015 /usr/lib64/*
 -rwxr-xr-x 1 root root 11508835 Apr 25 18:53 /usr/lib64/*
 #Notice the symbolic link to 6.0.22
 [root@backend lib64]# cd
 [root@backend ~]# strings /usr/lib64/ | grep GLIB

Before, we only had strings up until GLIBCXX_3.4.13, but now we have strings up until GLIBCXX_3.4.22. (Our version of Electron requires GLIBCXX_3.4.15)

Update glib library

Follow the nice instructions of some friendly gents over on GitHub to install an updated version of glib that will support Electron (NightmareJS).  More info:

[root@backend ~]# cd /opt
 [root@backend opt]# wget
 [root@backend opt]# tar xzf gcc-4.7.2.tar.gz
 [root@backend opt]# rm gcc-4.7.2.tar.gz
 [root@backend opt]# cd /etc/
 [root@backend]# nano gcc-4.7.2.conf

Into this file, paste the following:

[root@backend]# ldconfig
 [root@backend]# ldconfig -p | grep "libglib"

Check for glib-2.49.4.

Set up D-Bus library

This step might not be necessary.  On the first machine I performed these steps, I didn’t need to do this, but on the second one, I did.  When running your NightmareJS script, if you get an error about the D-Bus library not being set up correctly, execute this simple command (Thanks to Tork Wrench).

[root@backend ~]# dbus-uuidgen > /var/lib/dbus/machine-id

Finally – Running NightmareJS!

[dev@backend ~]$ cd project/
 [dev@backend your-project]$ rm -rf node_modules/
 [dev@backend your-project]$ npm install
 [dev@backend your-project]$ DEBUG=nightmare*,electron* xvfb-run -a --server-args="-screen 0 1280x2000x24" node your-script.js -- --progress=false --single-run --watch=false

Note – this is likely not the best command for you; in fact it almost certainly is not. Experimentation will be needed in adding/removing/changing flags.  However, this should hopefully be enough to verify that NightmareJS is in a functional state.

*I made it all the way through this post without making an obvious pun about how hard it is to get NightmareJS running on CentOS.  I hope I’ve made you proud!