代码之家  ›  专栏  ›  技术社区  ›  focode

运行puppyteerjs的nodejs程序失败

  •  0
  • focode  · 技术社区  · 5 年前

    我写了一个非常简单的puppyteerjs程序:

    const木偶师=要求(“供应商”);

    (async () => {
      const browser = await puppeteer.launch({ headless: false,
        slowMo: 250 });
      const page = await browser.newPage();
      await page.goto('https://example.com');
      await page.screenshot({path: 'example.png'});
    
      await browser.close();
    })();
    

    附言D:\js\puppe>节点。\screenshot.js (节点:2052)UnhandledPlosirejection警告:错误:启动浏览器进程失败!

    TROUBLESHOOTING: https://github.com/puppeteer/puppeteer/blob/master/docs/troubleshooting.md
    
        at onClose (D:\js\puppe\node_modules\puppeteer\lib\Launcher.js:750:14)
        at ChildProcess.helper.addEventListener (D:\js\puppe\node_modules\puppeteer\lib\Launcher.js:740:61)
        at ChildProcess.emit (events.js:194:15)
        at Process.ChildProcess._handle.onexit (internal/child_process.js:248:12)
    (node:2052) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
    (node:2052) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
    

    我在节点版本12和节点版本10上尝试了这个程序,我尝试了一个无头标志,并给出了节点模块中chrome.exe文件的路径,但它一直抛出相同的异常。

    我当前的环境是:windows 10和node 10

    0 回复  |  直到 5 年前