我試圖在Heroku,GAE flex,Digital Ocean和Vultr上運行谷歌瀏覽器木偶遊戲,但在我使用puppeteer的路線上,實例只是掛起與502錯誤我用這個簡單的代碼:在Vultr,Digital Ocean,Heroku或GAE上運行谷歌Chrome木偶遊戲
var express = require('express');
var router = express.Router();
const puppeteer = require('puppeteer');
router.get('/', function(req, res, next) {
(async() => {
const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.goto('http://example.com');
await page.screenshot({path: 'example.png'});
browser.close();
res.send('screen grabbed');
})();
});
module.exports = router;
我知道的木偶與節點6現在的工作,但我設置package.json
如下:
{
"name": "puppeteer",
"version": "0.0.0",
"private": true,
"scripts": {
"start": "node ./bin/www",
"deploy": "gcloud app deploy --version dev"
},
"engines": {
"node": "8.4.0"
},
"dependencies": {
"body-parser": "~1.17.1",
"cookie-parser": "~1.4.3",
"debug": "~2.6.3",
"express": "~4.15.2",
"morgan": "~1.8.1",
"pug": "~2.0.0-beta11",
"puppeteer": "^0.10.2",
"serve-favicon": "~2.4.2"
}
}
在Vultr的Ubuntu 16.04 64位,我得到出現以下錯誤:
Error: Failed to launch chrome!
/root/mysite/node_modules/puppeteer/.local-chromium/linux-497674/chrome-linux/chrome: error while loading shared libraries: libpangocairo-1.0.so.0: cannot open shared object file: No such file or directory