【发布时间】: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