Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save reqshark/56380afcf4985f018c08246b07818e3c to your computer and use it in GitHub Desktop.
Save reqshark/56380afcf4985f018c08246b07818e3c to your computer and use it in GitHub Desktop.
Running Nightmare headlessly on Linux

Installation

Installing dependencies

sudo apt-get install build-essential clang libdbus-1-dev libgtk2.0-dev \
                       libnotify-dev libgnome-keyring-dev libgconf2-dev \
                       libasound2-dev libcap-dev libcups2-dev libxtst-dev \
                       gcc-multilib g++-multilib \
                       libgtk2.0-0 libgconf-2-4 \
                       libasound2 libxtst6 libxss1 libnss3 xvfb \

Install NodeJS

Download nvm

wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.31.0/install.sh | bash

After install nvm, install a node version. For example:

nvm install v5.5.0

Close your terminal and open again.

Install Electron Pre-Built

In project folder run command

npm install electron-prebuilt@0.37.7 --save

Specify Electron Path

Add electronPath parameter

var nightmare = Nightmare({
  electronPath: require('electron-prebuilt')
});

Run Nightmare Script

xvfb-run -a node --harmony <your-script>

Your script didn't run?

DEBUG=nightmare:*,electron:* xvfb-run -a node --harmony <your-script>

OR

DEBUG=nightmare:*,electron:* node --harmony <your-script>

Check if there is not installed library. If you can not find the problem please visit this link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment