迁移服务器后,安装puppeteer的踩坑记录
本次安装,执行命令npm i puppeteer,报错
npm error **INFO** Skipping Firefox download as instructed.
npm error Error: ERROR: Failed to set up chrome v139.0.7258.66! Set "PUPPETEER_SKIP_DOWNLOAD" env variable to skip download.
npm error at downloadBrowser (file://node_modules/puppeteer/lib/esm/puppeteer/node/install.js:26:15)
npm error at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
npm error at async Promise.all (index 0)
npm error at async downloadBrowsers (file://node_modules/puppeteer/lib/esm/puppeteer/node/install.js:84:9) {
npm error [cause]: Error: read ECONNRESET
npm error at TLSWrap.onStreamRead (node:internal/stream_base_commons:216:20) {
npm error errno: -104,
npm error code: 'ECONNRESET',
npm error syscall: 'read'
npm error }
npm error }
从报错可知是下载chrome v139的时候抛出的,查阅代码后给出解决办法
export PUPPETEER_CHROME_HEADLESS_SHELL_DOWNLOAD_BASE_URL="https://cdn.npmmirror.com/binaries/chrome-for-testing" && export PUPPETEER_CHROME_DOWNLOAD_BASE_URL="https://cdn.npmmirror.com/binaries/chrome-for-testing" && npm i puppeteer
完成安装
完成后运行,报错
1、/root/.cache/puppeteer/chrome/linux-139.0.7258.66/chrome-linux64/chrome: error while loading shared libraries: libatk-1.0.so.0: cannot open shared object file: No such file or directory
2、error while loading shared libraries: libatk-bridge-2.0.so.0: cannot open shared object file: No such file or directory
3、/root/.cache/puppeteer/chrome/linux-139.0.7258.66/chrome-linux64/chrome: error while loading shared libraries: libcups.so.2: cannot open shared object file: No such file or directory
4、/root/.cache/puppeteer/chrome/linux-139.0.7258.66/chrome-linux64/chrome: error while loading shared libraries: libXcomposite.so.1: cannot open shared object file: No such file or directory
5、/root/.cache/puppeteer/chrome/linux-139.0.7258.66/chrome-linux64/chrome: error while loading shared libraries: libXdamage.so.1: cannot open shared object file: No such file or directory
6、/root/.cache/puppeteer/chrome/linux-139.0.7258.66/chrome-linux64/chrome: error while loading shared libraries: libXfixes.so.3: cannot open shared object file: No such file or directory
7、/root/.cache/puppeteer/chrome/linux-139.0.7258.66/chrome-linux64/chrome: error while loading shared libraries: libXrandr.so.2: cannot open shared object file: No such file or directory
8、/root/.cache/puppeteer/chrome/linux-139.0.7258.66/chrome-linux64/chrome: error while loading shared libraries: libXrandr.so.2: cannot open shared object file: No such file or directory
9、/root/.cache/puppeteer/chrome/linux-139.0.7258.66/chrome-linux64/chrome: error while loading shared libraries: libcairo.so.2: cannot open shared object file: No such file or directory
10、/root/.cache/puppeteer/chrome/linux-139.0.7258.66/chrome-linux64/chrome: error while loading shared libraries: libpango-1.0.so.0: cannot open shared object file: No such file or directory
11、/root/.cache/puppeteer/chrome/linux-139.0.7258.66/chrome-linux64/chrome: error while loading shared libraries: libasound.so.2: cannot open shared object file: No such file or directory
解决办法
1、sudo apt install libatk1.0-0
2、sudo apt install libatk-bridge2.0-0
3、sudo apt install libcups2
4、sudo apt install libxcomposite1
5、sudo apt install libxdamage1
6、sudo apt install libxfixes3
7、sudo apt install libxrandr2
8、sudo apt install libgbm1
9、sudo apt install libcairo2
10、sudo apt install libpango-1.0-0
11、sudo apt install libasound2t64
一步步解决吧,最终大功告成!!









