segment-boneyard / nightmare

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

Cannot find module 'browser-window' #416

Closed erch closed 8 years ago

erch commented 8 years ago

Hi,

Seems that there is an issue with the file runner.js when it run the statement require('browser-window'). I have tried several examples but I 'm always getting the same error. I'm running this on windows 10 and my node environement works fine for other applications.

> node --version
v5.3.0
>
> cat .\package.json
{
  "name": "webautomation",
  "version": "1.0.0",
  "private": true,
  "description": "testing nightmare.js",
  "main": "main.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "dependencies": {
    "nightmare": "^2.1.2",
    "vo": "^1.0.3"
  },
  "author": "ECH",

  "license": "ISC"
}
>
> npm install
>
> npm ls electron-prebuilt
webautomation@1.0.0 D:\MyEnv\WebAutomation
└─┬ nightmare@2.1.2

  └── electron-prebuilt@0.35.4
>
> cat .\main.js
var Nightmare = require('nightmare');
console.log("require done");
dream = Nightmare();

dream.goto('http://yahoo.com');
dream.end();
>
> node main.js
creation done
module.js:338
    throw err;
    ^

Error: Cannot find module 'browser-window'
    at Function.Module._resolveFilename (module.js:336:15)
    at Function.Module._load (module.js:286:25)
    at Module.require (module.js:365:17)
    at require (module.js:384:17)
    at Object.<anonymous>    (D:\MyEnv\WebAutomation\node_modules\nightmare\lib\runner.js:6:21)
    at Module._compile (module.js:434:26)
    at Object.Module._extensions..js (module.js:452:10)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)
    at Function.Module.runMain (module.js:475:10)
>

Can you help me to fix this issue ?

Thanks

matthewmueller commented 8 years ago

browser-window needs to be run by the electron process. it seems it's trying to do: node runner.js, which won't work.

erch commented 8 years ago

Hi matthew,

Do you mean that I should run the application differently than with : node <myapp> ?

rosshinkley commented 8 years ago

@erch Are you still experiencing this problem?

erch commented 8 years ago

@rosshinkley : thanks for the inquiry , I switched the project to my linux box and it works on it. I suppose that there was a issue with my windows node js installation.

Eric

rosshinkley commented 8 years ago

@erch Thanks for the response, sounds like it's resolved. If this crops up again, feel free to reopen/open a new issue.

csthaha commented 4 years ago

I have this problem, that is, I run the electron under Windows and then report the erro that cannot find module 'browser-window' .