Nightmare JS is a browser automation tool. It works perfectly on local machine and even has an option to view the browser in action by passing { show: true }
option when initializing Nightmare. On remote linux machine, however, it will not work without installing and including an extra package xvfb.
Below is how you can add it to your app for nightmare to work seamlessly:
const Nightmare = require('nightmare');
const Xvfb = require('xvfb');
let xvfb = new Xvfb();
try {
xvfb.startSync();
}
catch (e) {
console.log(e);
}
// now anywhere in the code you can create and use a nightmare instance
const nightmare = Nightmare({});
nightmare
.goto('https://www.techighness.com')
//...
Note that a machine that doesn’t have xvfb installed, it’ll just throw an error and still start the app, but nightmare code won’t work.
See also
- Node JS Mongo Client for Atlas Data API
- SignatureDoesNotMatch: The request signature we calculated does not match the signature you provided. Check your key and signing method.
- Exactly Same Query Behaving Differently in Mongo Client and Mongoose
- MongoDB Single Update Query to Change the Field Name in All Matching Documents of the Collection
- AWS Layer: Generate nodejs Zip Layer File Based on the Lambda's Dependencies
- In Node JS HTML to PDF conversion, Populate Images From URLs
- Convert HTML to PDF in Nodejs