sc-chrome-installer
v1.6.1
Published
A utility package to install Chrome for Web applications in Linux environments
Downloads
59
Maintainers
Readme
SC Chrome Installer
A utility package to automate Chrome installation for SC Web applications, particularly in Linux deployment environments.
Features
- Automatically installs Chrome during npm installation (Linux only)
- Skips installation on Windows environments
- Provides programmatic API to install Chrome or get the executable path
Installation
npm install --save sc-chrome-installerUsage
Automatic Installation
The package will automatically attempt to install Chrome during npm install on Linux environments. No additional action is required.
On Windows environments, installation is automatically skipped.
Programmatic Usage
const chromeInstaller = require('sc-chrome-installer');
// Install Chrome (if not on Windows)
const success = chromeInstaller.installChrome();
// Get Chrome executable path (returns null on Windows)
const chromePath = chromeInstaller.getChromeExecutablePath();Using with Puppeteer
After installation, configure Puppeteer to use the installed Chrome wrapper:
const puppeteer = require('puppeteer');
const browser = await puppeteer.launch({
executablePath: process.env.CHROME_EXECUTABLE_PATH,
args: ['--no-sandbox', '--disable-setuid-sandbox', '--disable-dev-shm-usage']
});Environment Variable
The installer sets the following environment variable:
CHROME_EXECUTABLE_PATH="/home/site/wwwroot/chromium/chrome-linux/chrome-wrapper"You can also set this manually if needed:
# For the current session
export CHROME_EXECUTABLE_PATH="/home/site/wwwroot/chromium/chrome-linux/chrome-wrapper"
# To persist across sessions, add to your .bashrc or .profile
echo "export CHROME_EXECUTABLE_PATH=/home/site/wwwroot/chromium/chrome-linux/chrome-wrapper" >> ~/.bashrcAzure App Service Deployment
When deploying to Azure App Service, the script will automatically install the required system libraries. You can use the following simplified startup command:
bash -c "npm install sc-chrome-installer && npx sc-chrome-installer && pm2 update && pm2 install pm2-logrotate && pm2 start /home/site/wwwroot/dist/server.bundle.js --name web --max-memory-restart 7G --no-daemon --time --env production"If you prefer to install the system dependencies separately, use this expanded command:
bash -c "apt-get update && apt-get install -y libx11-xcb1 libxcomposite1 libxcursor1 libxdamage1 libxi6 libxtst6 libnss3 libxrandr2 libasound2 libatk1.0-0 libatk-bridge2.0-0 libcups2 libdrm2 libgbm1 libgtk-3-0 libnspr4 libxss1 libxkbcommon0 libpango-1.0-0 libpangocairo-1.0-0 libatspi2.0-0 libxshmfence1 fonts-liberation fonts-noto-color-emoji xdg-utils || true && npm install sc-chrome-installer && npx sc-chrome-installer && pm2 update && pm2 install pm2-logrotate && pm2 start /home/site/wwwroot/dist/server.bundle.js --name web --max-memory-restart 7G --no-daemon --time --env production"Testing Chrome Installation
You can test if Chrome is correctly installed by running:
node src/bin/puppeteer-test.jsThis will generate a test report in your temp directory.
License
MIT
