【问题标题】:TypeError [ERR_INVALID_ARG_TYPE]: The "original" argument must be of type function puppeteer node jsTypeError [ERR_INVALID_ARG_TYPE]:“原始”参数必须是函数 puppeteer node js 类型
【发布时间】:2020-08-29 10:03:26
【问题描述】:

我在这里停留了一段时间,我不明白这个问题。请有人在这个话题上启发我。这是代码。

const puppeteer = require('puppeteer');
(async() => {
    let infourl = 'https://www.imdb.com/title/tt0111161/?ref_=fn_al_tt_3';
    let browser = await puppeteer.launch();
    let page = await browser.newPage();
    await page.goto(infourl, { waitUntil:'networkidle2' });
    let data = await page.evaluate( () =>{
        let stats = document.querySelector('div[class="title_wrapper"]').innerText;
        return {stats};
    });
    console.log(data);
    debugger;
    await browser.close();
})();

这是日志::

internal/util.js:209
    throw new errors.TypeError('ERR_INVALID_ARG_TYPE', 'original', 'function');
    ^

TypeError [ERR_INVALID_ARG_TYPE]: The "original" argument must be of type function
    at promisify (internal/util.js:209:11)
    at Object.<anonymous> (/home/hadi/Desktop/datachori/node_modules/extract-zip/index.js:11:18)
    at Module._compile (module.js:652:30)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
    at Function.Module._load (module.js:497:3)
    at Module.require (module.js:596:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/home/hadi/Desktop/datachori/node_modules/puppeteer/lib/BrowserFetcher.js:25:20)

【问题讨论】:

  • 我将我的节点版本从 8.0.0 更新到了最新推荐的 12.16.3,然后我再次安装了 puppeteer。这对我有用。希望这会有所帮助。谢谢

标签: node.js puppeteer node-promisify


【解决方案1】:

最新版本的 puppeteer 出现这种情况。
您的脚本将在较低版本中正常运行。

试试这个脚本:

npm i -save puppeteer@1.7.0

【讨论】:

  • 我将 node.js 版本从 8.0.0 更新到 12.16 .3,这是 nodejs.org 网站上推荐的,然后我重新安装了 puppeteer。这对我有用,非常感谢。
  • 这会产生另一个错误 --> Uncaught TypeError: Cannot read property 'bind' of undefined
【解决方案2】:

执行以下命令

npm config set PUPPETEER_SKIP_CHROMIUM_DOWNLOAD false

npm config set ignore-scripts false

然后:

npm config set ignore-scripts true

将忽略脚本的标志改回来,因为如果设置为 false,则会构成安全威胁

【讨论】:

  • 这个答案没有帮助
  • 对我节点 v14.17.1 LTS 也没有帮助
猜你喜欢
  • 1970-01-01
  • 2020-10-31
  • 1970-01-01
  • 2019-10-01
  • 2019-01-24
  • 2021-07-17
  • 2020-06-20
  • 2023-04-05
  • 2021-12-24
相关资源
最近更新 更多