首页 > 解决方案 > 如何修复找不到浏览器修订版 756035

问题描述

puppeteer用来执行一些测试用例Docker,我得到以下错误:

“首先”钩子:“Validate_onbord_broker_business”的codeceptjs.beforeSuite:找不到浏览器修订版756035。运行“npm install”或“yarn install”下载浏览器二进制文件。在 ChromeLauncher.launch (node_modules/puppeteer/lib/Launcher.js:59:23) 在异步 Puppeteer._startBrowser (node_modules/codeceptjs/lib/helper/Puppeteer.js:512:22)

这是Dockerfile我正在使用的:

# Use whatever version you are running locally (see node -v)
FROM node:12.18

WORKDIR /app

RUN  apt-get update \
     && apt-get install -y wget gnupg ca-certificates \
     && wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - \
     && sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list' \
     && apt-get update \
     && apt-get install -y google-chrome-stable \
     && rm -rf /var/lib/apt/lists/* \
     && wget --quiet https://raw.githubusercontent.com/vishnubob/wait-for-it/master/wait-for-it.sh -O /usr/sbin/wait-for-it.sh \
     && chmod +x /usr/sbin/wait-for-it.sh

# Install dependencies (you are already in /app)
COPY package.json package-lock.json ./
# RUN npm ci
RUN npm install
ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD true
RUN npm install codeceptjs puppeteer
COPY . /app

RUN pwd
RUN ls


# RUN npx codeceptjs init


RUN npx codeceptjs run 

# CMD ["npm", "start"]

有人可以帮我出什么问题吗?

标签: node.jsdockerpuppeteer

解决方案


我认为问题在于您在安装依赖项时跳过了下载 chromium 版本:ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD true. Puppeteer 只能保证与捆绑版本的 chromium 一起工作,使用其他版本的 chromium 通常是个坏主意。

根据您对帖子的评论,我您不使用捆绑版 Chromium 的原因是因为您对依赖项感到“乐趣”。这些可以使用手动安装apt- 以下是官方 puppeteer dockerfile安装的依赖项:

apt-get -y install xvfb gconf-service libasound2 libatk1.0-0 libc6 libcairo2 libcups2 \
      libdbus-1-3 libexpat1 libfontconfig1 libgbm1 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

我认为这是更新的Dockerfile- 让我知道它是否有效,因为没有你的其余代码我无法测试它!

# Use whatever version you are running locally (see node -v)
FROM node:12.18

WORKDIR /app

RUN  apt-get update \
     && apt-get -y install xvfb gconf-service gnupg libasound2 libatk1.0-0 libc6 libcairo2 libcups2 \
      libdbus-1-3 libexpat1 libfontconfig1 libgbm1 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 \
     && wget --quiet https://raw.githubusercontent.com/vishnubob/wait-for-it/master/wait-for-it.sh -O /usr/sbin/wait-for-it.sh \
     && chmod +x /usr/sbin/wait-for-it.sh

# Install dependencies (you are already in /app)
COPY package.json package-lock.json ./
# RUN npm ci
RUN npm install
RUN npm install codeceptjs puppeteer
COPY . /app

RUN pwd
RUN ls


# RUN npx codeceptjs init


RUN npx codeceptjs run 

# CMD ["npm", "start"]

推荐阅读