本文介绍了如何为Puppeteer安装Firefox?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
一段时间以来,我一直在尝试为puppeteer安装firefox,文档说要运行下一个命令:
I've been trying to install firefox for puppeteer for a while,the docs says to run the next command:
PUPPETEER_PRODUCT=firefox npm i puppeteer
但是我不知道在哪里运行它?我已经尝试过
But I can't understand where to run it?I've tried
npm config set puppeteer_product firefox
下载Nightly软件包但是当尝试运行puppeteer时,出现下一个错误:
Which downloads the Nightly packagebut then when trying to run puppeteer I get the next error:
(node:27840) UnhandledPromiseRejectionWarning: Error: Could not find browser revision 782078. Run "PUPPETEER_PRODUCT=firefox n
pm install" or "PUPPETEER_PRODUCT=firefox yarn install" to download a supported Firefox browser binary.
有人可以帮助我吗?
推荐答案
一旦您通过以下方式为人偶正确启用了Firefox:
Once you've correctly enabled Firefox for puppeteer with:
npm
PUPPETEER_PRODUCT=firefox npm install puppeteer
或纱线:
PUPPETEER_PRODUCT=firefox yarn add puppeteer
然后,您需要设置 puppeteer.launch
到'firefox'
:
const browser = await puppeteer.launch({ product: 'firefox' })
这篇关于如何为Puppeteer安装Firefox?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!