为什么我在 Ubuntu 18.04.4 LTS 上收到错误 运行 Puppeteer?

Why am I getting an error running Puppeteer on Ubuntu 18.04.4 LTS?

运行 具有相同设置的 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 18.04.4 上更新 Node.js 后,错误消息消失了。

有点相关。对于单个包,我在许多不同的 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 版本。