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']});


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM