Anonymous
Ошибка кукловода: не удалось найти Chrome (вер. 131.0.6778.204)
Сообщение
Anonymous » 26 фев 2025, 08:34
Я использую кукол для генерации PDF. Также я использую Selenium для Zerodha Automation. Мне нужно настроить файл Docker, чтобы хорошо работать как для Selenium, так и для кукловода.
Код: Выделить всё
FROM node:16-alpine
# Set the working directory
WORKDIR /app
# Install dependencies
RUN apk update && apk add --no-cache \
chromium \
chromium-chromedriver \
bash \
curl \
wget \
unzip \
make \
g++ \
&& npm install -g selenium-webdriver
# Set environment variables
ENV CHROME_BIN=/usr/bin/chromium-browser
ENV CHROMEDRIVER_PATH=/usr/bin/chromedriver
ENV PUPPETEER_SKIP_DOWNLOAD=true
# Copy application code
COPY package*.json ./
RUN npm install
COPY . .
# Expose the port
EXPOSE 8004
# Start the server
CMD ["node", "server.js"]
< /code>
Код, который я использую для генерации PDF < /p>
const browser = await puppeteer.launch({ headless: "new",
args: ['--no-sandbox', '--disable-setuid-sandbox'],
});
const page = await browser.newPage();
await page.setContent(req.query.html, { waitUntil: 'domcontentloaded' });
await page.emulateMediaType('screen');
await page.waitForSelector('body', { visible: true });
await delay(2000);
const pdf = await page.pdf({
path: 'result.pdf',
margin: { top: '100px', right: '50px', bottom: '100px', left: '50px' },
printBackground: true,
format: 'A4',
});
await browser.close();
< /code>
В AWS EC2 я получаю приведенную ниже ошибку < /p>
message: 'Could not find Chrome (ver. 131.0.6778.204). This can occur if either\n' +
' 1. you did not perform an installation before running the script (e.g. npx puppeteer browsers install chrome) or\n' +
' 2. your cache path is incorrectly configured (which is: /root/.cache/puppeteer).\n' +
'For (2), check out our guide on configuring puppeteer at https://pptr.dev/guides/configuration.',
data: undefined
Пожалуйста, помогите мне исправить эту ошибку.
Подробнее здесь:
https://stackoverflow.com/questions/794 ... 0-6778-204
1740548073
Anonymous
Я использую кукол для генерации PDF. Также я использую Selenium для Zerodha Automation. Мне нужно настроить файл Docker, чтобы хорошо работать как для Selenium, так и для кукловода.[code]FROM node:16-alpine # Set the working directory WORKDIR /app # Install dependencies RUN apk update && apk add --no-cache \ chromium \ chromium-chromedriver \ bash \ curl \ wget \ unzip \ make \ g++ \ && npm install -g selenium-webdriver # Set environment variables ENV CHROME_BIN=/usr/bin/chromium-browser ENV CHROMEDRIVER_PATH=/usr/bin/chromedriver ENV PUPPETEER_SKIP_DOWNLOAD=true # Copy application code COPY package*.json ./ RUN npm install COPY . . # Expose the port EXPOSE 8004 # Start the server CMD ["node", "server.js"] < /code> Код, который я использую для генерации PDF < /p> const browser = await puppeteer.launch({ headless: "new", args: ['--no-sandbox', '--disable-setuid-sandbox'], }); const page = await browser.newPage(); await page.setContent(req.query.html, { waitUntil: 'domcontentloaded' }); await page.emulateMediaType('screen'); await page.waitForSelector('body', { visible: true }); await delay(2000); const pdf = await page.pdf({ path: 'result.pdf', margin: { top: '100px', right: '50px', bottom: '100px', left: '50px' }, printBackground: true, format: 'A4', }); await browser.close(); < /code> В AWS EC2 я получаю приведенную ниже ошибку < /p> message: 'Could not find Chrome (ver. 131.0.6778.204). This can occur if either\n' + ' 1. you did not perform an installation before running the script (e.g. npx puppeteer browsers install chrome) or\n' + ' 2. your cache path is incorrectly configured (which is: /root/.cache/puppeteer).\n' + 'For (2), check out our guide on configuring puppeteer at https://pptr.dev/guides/configuration.', data: undefined [/code] Пожалуйста, помогите мне исправить эту ошибку. Подробнее здесь: [url]https://stackoverflow.com/questions/79468575/puppeteer-error-could-not-find-chrome-ver-131-0-6778-204[/url]