Studiosity / grover

A Ruby gem to transform HTML into PDFs, PNGs or JPEGs using Google Puppeteer/Chromium
MIT License
937 stars 107 forks source link

Puppeteer module not found when using yarn 4 #261

Closed bradherman closed 1 month ago

bradherman commented 1 month ago

Started noticing I was getting Module not found errors for puppeteer...

yarn@4.4.1
node@18.20.2
ruby@3.3.5
grover@1.1.9
puppeteer@23.4.1
rails@6.1.7.8

Tried setting the options in initializer to the Rails root with no luck... If I switch over to npm 10.8.3, however, the gem is able to find puppeteer...

Thoughts?

abrom commented 1 month ago

are you installing puppeteer locally? Or globally?

if you run the following (with a node shell launched from the root of your project), does it list the path where you've installed puppeteer?

const Module = require('module')
Module._nodeModulePaths(process.cwd())

Unrelated to your issue, i can also see another issue which is an incompatibility between Grover and puppeteer versions. See https://github.com/Studiosity/grover/blob/main/CHANGELOG.md#1110---2024-09-01

bradherman commented 1 month ago

@abrom I think the issue here is that after upgrading to Yarn 4, they use the PnP strategy by default... this means no node_modules folder, so I think the Grover check for puppeteer just isn't compatible with the new strategy... puppeteer IS installed, but the check in https://github.com/Studiosity/grover/blob/38e4b2d0feb8726f592c8f85137c2e54d58afc96/lib/grover/processor.rb#L42C1-L43C1 doesn't work with the .pnp.cjs strategy

verified that if I set nodeLinker: node-modules option in .yarnrc.yml that it works as expected (because we get a node_modules folder)

bradherman commented 1 month ago

This should help:

https://github.com/Studiosity/grover/pull/262

abrom commented 1 month ago

Nice one, thanks @bradherman 👍