neocotic / convert-svg

Node.js packages for converting SVG into other formats using headless Chromium
MIT License
200 stars 47 forks source link

Chromium revision is not downloaded #67

Closed CeamKrier closed 5 years ago

CeamKrier commented 5 years ago

I have been trying to use the svg-to-png version of the converter on the nodeJS platform and the module was firing the error below:

UnhandledPromiseRejectionWarning: Error: Chromium revision is not downloaded. Run "npm install" or "yarn install"

So after the frustrating search of a few hours I managed to resolve the issue with the following addition to the convert function

executablePath: './node_modules/puppeteer/.local-chromium/win64-686378/chrome-win/chrome.exe'

The issue there is, chromium instance could not be found by the module thus it is throwing the error no matter what you do. After installing the module, get the path of your chrome.exe instance just like I did above. And add it to your puppeteer launch options like below:

const png = await convert(string, { width: parseInt(request.params.width || 500, 10), puppeteer: { args: ['--no-sandbox', '--disable-setuid-sandbox'], executablePath: './node_modules/puppeteer/.local-chromium/win64-686378/chrome-win/chrome.exe' } });

This shall resolve the issue. I hope that saves time for the ones that look to find an answer to this error.