【问题标题】:Why am I getting an error running Puppeteer on Ubuntu 18.04.4 LTS?为什么我在 Ubuntu 18.04.4 LTS 上运行 Puppeteer 时出错?
【发布时间】:2020-08-15 03:12:45
【问题描述】:

使用相同设置运行 Puppeteer 运行良好,直到在 ubuntu VPS 上部署时出现以下错误:

    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> (/var/www/html/path/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> (/var/www/html/path/node_modules/puppeteer/lib/BrowserFetcher.js:25:17)

这是我的源代码:

    const puppeteer = require('puppeteer');

(async() => {

    const browser = await puppeteer.launch({args: ['--no-sandbox', '--disable-setuid-sandbox']});
    const page = await browser.newPage();
    browser.close();

})();

请帮忙。我错过了什么。为什么我在 ubuntu 16 VPS 上出现错误,但在我的 mac 上一切正常。

【问题讨论】:

  • 您是否在项目文件夹内的 ubuntu vps 上运行了 npm install ?
  • 是的,我做了 Anees。
  • 您使用的是最新版本的 nodejs 吗?因为如果您使用 apt 安装它,那么您很可能使用的是旧版本的 nodejs。
  • 我是用apt安装的。版本是8版
  • 你需要将节点 js 更新到当前版本。 stackoverflow.com/questions/41195952/…这里有一个主题可以帮助你做到这一点。

标签: node.js puppeteer ubuntu-18.04


【解决方案1】:

我在 Ubuntu 18.04.4 上更新了 Node.js 后,错误消息消失了。

【讨论】:

    【解决方案2】:

    有点相关。对于单个包,我在许多不同的 Node.js 版本中遇到了相同的错误:

    internal/util.js:220
    throw new errors.TypeError('ERR_INVALID_ARG_TYPE', 'original', 'Function');
    

    更新 Node.js 版本没有帮助。

    [解决方案]

    这很容易解决。 package.json 中引用的一些依赖项可能引用 32bit 包。如果您运行的是 64 位 Node.js 版本,则在尝试“npm run/start”、“npm test”或“npm install”包时会出现上述错误。

    只需切换到项目支持的受支持的 32 位 Node.js 版本。

    【讨论】:

      猜你喜欢
      • 2018-05-19
      • 2020-06-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-08-29
      • 1970-01-01
      相关资源
      最近更新 更多