segment-boneyard / nightmare

A high-level browser automation library.
https://open.segment.com
19.54k stars 1.08k forks source link

Module not found with vue-cli-plugin-electron-builder #1578

Open david-maus opened 4 years ago

david-maus commented 4 years ago

Hi, I'm a little bit lost with the following:

Using https://github.com/nklayman/vue-cli-plugin-electron-builder for the Electron app i cannot get nightmare to run.

I have tried the multiple answers with different electronPath values from similiar issues etc...

Any ideas?

const Nightmare = require('nightmare');
const nightmare = Nightmare({
    electronPath: require('../node_modules/electron'), //
    show: true,
});

nightmare
  .goto('https://duckduckgo.com')
  .type('#search_form_input_homepage', 'github nightmare')
  .click('#search_button_homepage')
  .wait('#r1-0 a.result__a')
  .evaluate(() => document.querySelector('#r1-0 a.result__a').href)
  .end()
  .then(console.log)
  .catch(error => {
    console.error('Search failed:', error)
  })
lib sync?cf1b:2 Uncaught Error: Cannot find module 'D:\xxxxxxx\src\frontend\node_modules\nightmare\package.json'
    at webpackEmptyContext (eval at ./node_modules/nightmare/lib sync recursive (app.js:2757), <anonymous>:2:10)
    at Object.eval (nightmare.js?5d42:278)
    at eval (nightmare.js:587)
    at Object../node_modules/nightmare/lib/nightmare.js (app.js:2802)
    at __webpack_require__ (app.js:770)
    at fn (app.js:130)
    at eval (main.js?56d7:20)
    at Module../src/main.js (app.js:3988)
    at __webpack_require__ (app.js:770)
    at fn (app.js:130)