1. 程式人生 > >ubuntu 安裝puppeteer,linux使用puppeteer

ubuntu 安裝puppeteer,linux使用puppeteer

在安裝puppeteer過程中遇到一些錯誤,記錄一下

首先可能遇到node install.js錯誤,可以使用一下命令引數安裝puppeteer

npm i --save puppeteer --ignore-scripts
或者先執行一下命令再安裝puppeteer
npm config set unsafe-perm true
npm i puppeteer

其次可能會遇到各種庫沒有安裝的錯誤,比如libX11-xcb.so.1,具體所需依賴可以檢視Troubleshooting.或直接執行一下命令

sudo apt install gconf-service libasound2 libatk1.0
-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 ca-certificates fonts-liberation libappindicator1 libnss3 lsb-release xdg-utils wget

還有sandbox 問題,可以嘗試在無沙箱模式下執行puppeteer

const browser = await puppeteer.launch({args: ['--no-sandbox', '--disable-setuid-sandbox']});