0

Running Puppeteer with the same setup runs fine until deployment on ubuntu VPS where I get the following error:

    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)

here's my source code:

    const puppeteer = require('puppeteer');

(async() => {

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

})();

Please help. What am I missing. Why am I getting the error on ubuntu 16 VPS but everything runs fine on my mac.

Mickael B.
  • 4,755
  • 4
  • 24
  • 48

2 Answers2

1

The error message have disappeared after I have updated my Node.js on Ubuntu 18.04.4.

BaseScript
  • 381
  • 2
  • 7
0

Slightly related. I had the same error across many different Node.js versions for a single package:

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

Updating Node.js versions did not help.

[Solution]

It's an easy fix. Some dependencies referenced in package.json may refer to 32bit packages. If you are running a 64bit Node.js version, you get the above error when trying to 'npm run/start', 'npm test', or 'npm install' the package.

Simply switch to a supported 32bit Node.js version that the project supports.

todef96
  • 546
  • 5
  • 2