ubuntu에서 puppeteer 실행 오류

shelly·2020년 9월 14일
1

상황

Ubuntu18 에서 node.js의 puppeteer module을 사용했다. 그런데 실행이 안된다.

오류 메시지

/root/node_modules/puppeteer/.local-chromium/linux-800071/chrome-linux/chrome: error while loading shared libraries: libgbm.so.1: cannot open shared object file: No such file or directory


TROUBLESHOOTING: https://github.com/puppeteer/puppeteer/blob/main/docs/troubleshooting.md

    at onClose (/root/node_modules/puppeteer/lib/cjs/puppeteer/node/BrowserRunner.js:193:20)
    at Interface.<anonymous> (/root/node_modules/puppeteer/lib/cjs/puppeteer/node/BrowserRunner.js:183:68)
    at Interface.emit (events.js:326:22)
    at Interface.close (readline.js:424:8)
    at Socket.onend (readline.js:202:10)
    at Socket.emit (events.js:326:22)
    at endReadableNT (_stream_readable.js:1252:12)
    at processTicksAndRejections (internal/process/task_queues.js:80:21)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:28207) 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(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:28207) [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.
^Croot@gcloud-seoul-4157f23167c3094e65f8465be8f65f1e:~# sudo apt-get install libgbm-dev

해결 방법

Ubuntu에 아래의 명령어를 실행한다.

$ sudo apt-get install libgtk2.0-0 libgtk-3-0 libnotify-dev
$ sudo apt-get install libgconf-2-4 libnss3 libxss1
$ sudo apt-get install libasound2 libxtst6 xauth xvfb
$ sudo apt-get install libgbm-dev

nodejs의 puppeteer 를 선언 시 아래와 같은 args를 추가한다.

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

1개의 댓글

comment-user-thumbnail
2020년 12월 11일

딱 똑같은 에러를 만났는데 감사합니다!!

답글 달기