I know that the title of the question looks very vague! But it is there.
I installed nodejs on my production server that had the correct phantomjs, then I installed the nightmare via npm install nightmare , I see it in node_modules, I tried the example given by the developers on github:
var Nightmare = require('nightmare'); var nightmare = Nightmare({ show: true }) nightmare .goto('http://yahoo.com') .type('input[title="Search"]', 'github nightmare') .click('#uh-search-button') .wait('#main') .evaluate(function () { return document.querySelector('#main .searchCenterMiddle li a').href }) .end() .then(function (result) { console.log(result) })
Nothing happened, the script didn’t output anything, I simplified the script to a simple single goto, for the page on my server this page was never called when I ran the script through node file.js
I have CentOS 6.7, phantomjs 1.1 I also tested it on a new CentOS 7 installation with the latest phantomjs. Same.
Am I missing some precondition or something else? How to debug a problem since node script.js gives no output
UPDATE: Apparently, the problem is that the electron used by the nightmare “instead of phantoms” requires a graphical environment, so it does not start in my environment.
source share