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
- JavaScript Rollbar: Unknown Unhandled Rejection Error Getting Reason From Event
- Remove Eslint Warnings For Dynamic Imports
- Nodejs Script to Add Rows in CSV File Through Terminal
- How to Deal With Nightmare JS Zombie Electron Processes
- Restart Pm2 Process Every Day Using A Node Script
- Trace Redirect Urls NPM Request
- Clean Up MongoDB Of Old Inactive Users And Their Data With Node Js Script