最新消息: 电脑我帮您提供丰富的电脑知识,编程学习,软件下载,win7系统下载。

Lighthouse Node JS模块没有返回结果

IT培训 admin 9浏览 0评论

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');
});
});
回答如下:

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. 暂无评论