Javascript 无法读取属性';码头';未定义噩梦的定义

Javascript 无法读取属性';码头';未定义噩梦的定义,javascript,node.js,nightmare,Javascript,Node.js,Nightmare,这是我的代码。我正在尝试使用噩梦.js刮取一个网站。但是每当我运行这段代码时,我都会得到一个错误。我已经在下面陈述了错误 const { csvFormat } = require('d3-dsv'); const Nightmare = require('nightmare'); const { readFileSync, writeFileSync } = require('fs'); const numbers = readFileSync('./tesco-title-numbers.c

这是我的代码。我正在尝试使用噩梦.js刮取一个网站。但是每当我运行这段代码时,我都会得到一个错误。我已经在下面陈述了错误

const { csvFormat } = require('d3-dsv');
const Nightmare = require('nightmare');
const { readFileSync, writeFileSync } = require('fs');
const numbers = readFileSync('./tesco-title-numbers.csv',
  {encoding: 'utf8'}).trim().split('\n');

const START = 'https://eservices.landregistry.gov.uk/wps/portal/Property_Search';
const getAddress = async id => {
  console.log(`Now checking ${id}`);
  const nightmare = new Nightmare({ show: true });
  // Go to initial start page, navigate to Detail search
  try {
    await nightmare
      .goto(START)
      .wait('.bodylinkcopy:first-child')
      .click('.bodylinkcopy:first-child');
  } catch(e) {
    console.error(e);
  }
  //***********************
  // Type the title number into the appropriate box; click submit
  try {
    await nightmare
      .wait('input[name="titleNo"]')
      .type('input[name="titleNo"]', id)
      .click('input[value="Search »"]');
  } catch(e) {
    console.error(e);
  }
  //***********************
  try {
  const result = await nightmare
    .wait('.w80p')
    .evaluate(() => {
      return [...document.querySelectorAll('.w80p')]
        .map(el => el.innerText);
    })
    .end();
  return { id, address: result[0], lease: result[1] };
} catch(e) {
  console.error(e);
  return undefined;
}
//***********************************
};

//working of app begins here
getAddress(numbers[0])
  .then(a => console.dir(a))
  .catch(e => console.error(e));
这是我得到的输出:

PS D:\web-scraping2> node app.js
Now checking HP431696
Nightmare runner error:

    TypeError: Cannot read property 'dock' of undefined
        at Object.<anonymous> (D:\web-scraping2\node_modules\nightmare\lib\runner.js:58:29)

        at Object.<anonymous> (D:\web-scraping2\node_modules\nightmare\lib\runner.js:652:3)
        at Module._compile (module.js:571:32)
        at Object.Module._extensions..js (module.js:580:10)
        at Module.load (module.js:488:32)
        at tryModuleLoad (module.js:447:12)
        at Function.Module._load (module.js:439:3)
        at Module.runMain (module.js:605:10)
        at run (bootstrap_node.js:431:7)
        at startup (bootstrap_node.js:155:9)
PS D:\web-scraping2>node app.js
现在检查HP431696
噩梦运行程序错误:
TypeError:无法读取未定义的属性“dock”
反对。(D:\web-scraping2\node\u modules\噩梦\lib\runner.js:58:29)
反对。(D:\web-scraping2\node\u modules\噩梦\lib\runner.js:652:3)
在模块处编译(模块js:571:32)
在Object.Module.\u extensions..js(Module.js:580:10)
在Module.load(Module.js:488:32)
在tryModuleLoad时(module.js:447:12)
在Function.Module.\u加载(Module.js:439:3)
位于Module.runMain(Module.js:605:10)
运行时(bootstrap_node.js:431:7)
启动时(bootstrap_node.js:155:9)

我已经安装了node dock、runner js模块,但仍然无法工作。我还将nodeJS更新为最新版本。我正在使用windows终端来执行我的代码。

因此我检查了runner.js文件,我发现它写在第58行的正上方:“app.dock在除OS X以外的平台上运行electron时未定义。”作为注释。我认为这就是错误的原因。由于我运行的是windows平台,解决方案是什么?因此我发现了问题,这是因为我使用的是atom ide(平台ide终端)包中的终端。非常感谢您对您的解决方案发表评论!可能至少为我节省了一个小时的故障排除时间。也许更多。