我很难从 nodejs 运行噩梦。我从自述文件中提供的示例开始,尝试了不同版本的电子预构建和不同的调整,但我总是得到找不到浏览器窗口模块的节点。这是我的测试:
> 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)
>
有人可以告诉我我在这里缺少什么吗?