{
"scripts": {
"test": "npx ts-mocha -p ./tsconfig.json *.spec.{js,ts}"
},
"dependencies": {
"mocha": "6.1.4",
"puppeteer": "*",
"ts-mocha": "6.0.0",
"typescript": "3.5.2"
},
"devDependencies": {
"@types/expect": "1.20.4",
"@types/mocha": "5.2.7",
"@types/puppeteer": "*"
}
}
FROM node:12.4.0-alpine
# install headless chrome
# ENV CHROME_BIN="/usr/bin/chromium-browser"
RUN echo http://dl-cdn.alpinelinux.org/alpine/edge/community >> /etc/apk/repositories \
&& echo http://dl-cdn.alpinelinux.org/alpine/edge/main >> /etc/apk/repositories \
&& apk upgrade \
&& apk update \
&& apk add --no-cache \
ttf-freefont \
chromium
# ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD true
COPY ./package.json /package.json
RUN npm i
# Add user so we don't need --no-sandbox.
RUN addgroup -S pptruser && adduser -S -g pptruser pptruser \
&& mkdir -p /home/pptruser/Downloads /app \
&& chown -R pptruser:pptruser /home/pptruser \
&& chown -R pptruser:pptruser /node_modules \
&& chmod
# Run everything after as non-privileged user.
USER pptruser
import puppeteer from 'puppeteer'
describe('academy', function() {
let browser: puppeteer.Browser;
let page: puppeteer.Page;
before(async function() {
browser = await puppeteer.launch({ headless: true })
page = await browser.newPage();
});
});
Error shows when npm run test
$ npm run test
Error: Failed to launch chrome! spawn /node_modules/puppeteer/.local-chromium/linux-669486/chrome-linux/chrome ENOENT
ENOENT: No such file or directory
Error No Entry
orError No Entity
Check existence of /node_modules/puppeteer/.local-chromium/linux-669486/chrome-linux/chrome
$ ls -lha /node_modules/puppeteer/.local-chromium/linux-669486/chrome-linux/chrome
-rwxr-xr-x 1 pptruser pptruser 822.8M Jun 24 11:35 /node_modules/puppeteer/.local-chromium/linux-669486/chrome-linux/chrome
Use ldd (Link Dynamic Dependencies) command to check dependencies
$ ldd /node_modules/puppeteer/.local-chromium/linux-669486/chrome-linux/chrome | grep not
Error loading shared library ld-linux-x86-64.so.2: No such file or directory (needed by ./chrome)
Error relocating ./chrome: __sbrk: symbol not found
Error relocating ./chrome: __res_nclose: symbol not found
Error relocating ./chrome: __res_ninit: symbol not found
Error relocating ./chrome: __vsnprintf_chk: symbol not found
Error relocating ./chrome: __isnanf: symbol not found
Error relocating ./chrome: __isnan: symbol not found
Error relocating ./chrome: __isinf: symbol not found
Error relocating ./chrome: __strncpy_chk: symbol not found
Error relocating ./chrome: __longjmp_chk: symbol not found
Error relocating ./chrome: strtoll_l: symbol not found
Error relocating ./chrome: strtoull_l: symbol not found
Error relocating ./chrome: gnu_get_libc_version: symbol not found
Error relocating ./chrome: __fdelt_chk: symbol not found
Error relocating ./chrome: backtrace: symbol not found
Error relocating ./chrome: __strncat_chk: symbol not found
Error relocating ./chrome: __fprintf_chk: symbol not found
Error relocating ./chrome: __sprintf_chk: symbol not found
Error relocating ./chrome: initstate_r: symbol not found
Error relocating ./chrome: random_r: symbol not found
Error relocating ./chrome: getcontext: symbol not found
Error relocating ./chrome: __isinff: symbol not found
Error relocating ./chrome: __vfprintf_chk: symbol not found
Error relocating ./chrome: __register_atfork: symbol not found
Error relocating ./chrome: __longjmp_chk: symbol not found
Error relocating ./chrome: __libc_stack_end: symbol not found
Segmentation fault
Error loading shared library ld-linux-x86-64.so.2: No such file or directory
- ld: Dynamic Linker
- .so: shared object (shared binary libirary)
libFOO.so.MAJOR.MINOR.PATCH