I wrote a little puppeteer program that let me log into twitter and check a few things. Locally on mac OS Catalina, it is working but on VPS ubuntu 18.04 lts not working. And shows me a log at the start:
/root/retwiter/node_modules/puppeteer/.local-chromium/linux-800071/chrome-linux/chrome: error while loading shared libraries: libnss3.so: cannot open shared object file: No such file or directory
I have 2 running configs for browser: local:
{
headless: false,
defaultViewport: null,
args: [
'--window-size=1920,1080'
]
}
vps:
{
headless: true,
defaultViewport: null,
args: [
'--no-sandbox',
'--disable-setuid-sandbox'
]
}
Memory requirements Actors using Puppeteer: at least 1GB of memory. Large and complex sites like Google Maps: at least 4GB for optimal speed and concurrency.
Puppeteer runs headless by default, but can be configured to run full (non-headless) Chrome or Chromium.
Advertisements. By default, Puppeteer executes the test in headless Chromium. This means if we are running a test using Puppeteer, then we won't be able to view the execution in the browser. To enable execution in the headed mode, we have to add the parameter: headless:false in the code.
Puppeteer is a Node. js library developed by Google that lets you control headless Chrome through the DevTools Protocol. It is a tool for automating testing in your application using headless Chrome or Chromebit devices, without requiring any browser extensions like Selenium Webdriver or PhantomJS.
i think you are missing the library libnss3 , try to install it using
sudo apt-get install libnss3-dev
and if that's not enough install all the deps for puppeteer
sudo apt-get install -y gconf-service libasound2 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 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 libgbm-dev
You can add AWS Elastic Beanstalk configuration files (.ebextensions
) to your web application's source code to configure your environment and customize the AWS resources that it contains.
In our case, if we don't enable EPEL and if we continue installing Chromium as part of npm install, Puppeteer cannot launch Chromium due to unavailability of libatk-1.0.so.0
.
Add the following to your app root:
.npmrc
file..npmrc
file:unsafe-perm=true
The .npmrc
file defines how npm should behave when running commands. Setting unsafe-perm
to true
suppress the UID/GID switching when running package scripts. Set the unsafe-perm flag to run scripts with root privileges.
.ebextensions
folder..ebextensions
folder, create a 01_enableEPEL.config
file and add the following.commands:
01_enableEPEL:
command: sudo amazon-linux-extras install epel -y
.ebextensions
folder, create a 02_installEPELPackages.config
file and add the followingpackages:
yum:
chromium: []
You can view the same guide on my GitHub @ https://github.com/amarinediary/Marionette
If on CentOS, you can use this command with the correct dependencies:
sudo yum install -y alsa-lib.x86_64 atk.x86_64 cups-libs.x86_64 gtk3.x86_64 ipa-gothic-fonts libXcomposite.x86_64 libXcursor.x86_64 libXdamage.x86_64 libXext.x86_64 libXi.x86_64 libXrandr.x86_64 libXScrnSaver.x86_64 libXtst.x86_64 pango.x86_64 xorg-x11-fonts-100dpi xorg-x11-fonts-75dpi xorg-x11-fonts-cyrillic xorg-x11-fonts-misc xorg-x11-fonts-Type1 xorg-x11-utils
sudo yum update nss -y
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With