最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Lighthouse Node JS模块没有返回结果

运维笔记admin16浏览0评论

Lighthouse Node JS模块没有返回结果

Lighthouse Node JS模块没有返回结果

我使用Node JS以编程方式使用灯塔。以前设法得到结果,但现在我似乎无法得到结果。检查了端口并注意到网站已打开但灯塔未运行。

Chrome Launcher版本为“^ 0.10.2”,Lighthouse版本为^ 2.8.0

"use strict";

const lighthouse = require('lighthouse');
const chromeLauncher = require('chrome-launcher');

function launchChromeAndRunLighthouse(url, flags = {}, config = null) {
return chromeLauncher.launch(flags).then(chrome => {
    flags.port = chrome.port;
    console.log(chrome.port);
    return lighthouse(url, flags, config).then(results =>
        chrome.kill().then(() => results));
});
}

const flags = {
 chromeFlags: ['disable-gpu','--headless']
};

launchChromeAndRunLighthouse('', flags).then(results => {
fs.appendFile('result.txt', JSON.stringify(results), (err) => {
    console.log('error appending to file example.txt');
});
});
回答如下:
发布评论

评论列表(0)

  1. 暂无评论