Generating PDF using pupeeter in Node.js

I have deployed my MERN web app.On localhost pdf file is being generated successfully but after deployment i getting this error,
“msg”: “Could not find Chrome (ver. 119.0.6045.105). This can occur if either\n 1. you did not perform an installation before running the script (e.g. npm install) or\n 2. your cache path is incorrectly configured (which is: /opt/render/.cache/puppeteer).\nFor (2), check out our guide on configuring puppeteer at https://pptr.dev/guides/configuration.
Help of any professional would be appreciated.

1 Like

Hi there,

Out of curiosity, did you try either of the suggestions in the error message? Beyond that, have you tried any online research on the error for solutions? That’s where I recommend starting.

Regards,
Mike


Render Support Engineer, MT (UTC-6)

Same for me, any solutions?

Hi @Mike_Marinaro, i have the same issue exactly as @Haris-Dux has, but when the logs says the reason it could not find chrome was that i did not perform npm intsall before running the script is absurd to me, because all the necessary packages like puppeteer and cheerio are clearly defined as dependencies in my package.json, so i would say i have done that, as for number 2, i have no idea what it meant, i trie to create a puppeteerrc.cjs config file: `const { join } = require(‘path’)

module.exports = {
cacheDirectory: join(__dirname, ‘.cache’, ‘puppeteer’)
}
` but that did not fix the issue so help please, should i provide my mail for better communication?

Hi there,

To clarify, just because dependencies are listed in a package.json file does not mean they will automatically get installed from there. A call to npm install (in this case) in the build command is typically still needed to actually install those dependencies. Is this being done in your situation? This type of error is typically not caused by the platform, but rather with the configuration/dependency setup.

Regards,
Mike


Render Support Engineer, MT (UTC-6)

Hi,
I did a lot of research.The only solution to this problem is you have to create containers using Dockers and then deploy it.

when the logs says the reason it could not find chrome

It means that you have to provide this dependency in that specific container.
I was short on delivery time so i used JS PDF in react on successful API call.
Hope it helps.

1 Like

Hey Mike,
I did a lot of research.The only solution to this problem is you have to create containers using Dockers and then deploy it.

when the logs says the reason it could not find chrome

It means that you have to provide this dependency in that specific container.
I was short on delivery time so i used JS PDF in react on successful API call.
Hope it helps.

Hi there,

Thanks for letting us know what worked for you.

It is true that any system tools/utilities not included in our builds would have to fall back on Docker to work on Render.

Regards,
Mike


Render Support Engineer, MT (UTC-6)

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.