unlighthouse icon indicating copy to clipboard operation
unlighthouse copied to clipboard

Cannot find module puppeteer

Open Tragio opened this issue 2 years ago • 6 comments

Hi @harlan-zw 👋

As you can see in the image unlighthouse never picks puppeteer, even though it is installed globally. I'm using nvm and the path would be /Users/tragio/.nvm/versions/node/v14.19.1/lib/node_modules/ and not file:///Users/tragio, file:///Users/tragio/node_modules as stated in the error message 🤔 I wonder if the error is related to that.

CleanShot 2022-04-21 at 09 14 49

Thank you for your amazing work 🙏

Tragio avatar Apr 21 '22 21:04 Tragio

Same here

zuramai avatar Apr 25 '22 01:04 zuramai

Hey @Tragio, @zuramai, sorry you had issues with the package.

I've made a binary that depends on puppeteer to try to get around this issue. Could someone try the below:

Using pnpm

pnpm dlx unlighthouse-puppeteer --site example.com

Using npx

npx unlighthouse-puppeteer --site example.com

harlan-zw avatar May 09 '22 11:05 harlan-zw

@harlan-zw I tried to use but still had the same error Failed to find a chrome / chromium binary to run. Add the puppeteer dependency to your project to resolve. Error: Cannot find module puppeteer imported from file:///Users/tragio, file:///Users/tragio/node_modules

Tragio avatar May 09 '22 13:05 Tragio

Ah damn, sorry it's not something I can replicate so just trying to fix it based on what I think the issue is.

Could you try one thing for me, install the package as a global dependencies and try run it

npm install -g unlighthouse-puppeteer
unlighthouse-puppeteer --site example.com

harlan-zw avatar May 09 '22 15:05 harlan-zw

Ah damn, sorry it's not something I can replicate so just trying to fix it based on what I think the issue is.

Could you try one thing for me, install the package as a global dependencies and try run it


npm install -g unlighthouse-puppeteer


unlighthouse-puppeteer --site example.com

Hmmm all the same, unfortunately. If you want send me DM on Twitter and we can do more tests and debug it easier.

Tragio avatar May 09 '22 16:05 Tragio

Hi, I'm getting the very same error even after trying these alternatives

lasfito avatar Oct 07 '22 08:10 lasfito

@harlan-zw does this help?

CleanShot 2023-03-02 at 13 39 51@2x

Tragio avatar Mar 02 '23 13:03 Tragio

This might be caused by a different channel of Chrome being installed, so puppeteer cannot find it.

In my case, I have Chrome Dev installed.

I fixed the issue by defining the path to the Chrome executable in unlighthouse.config.ts (your Chrome path may be different to this):

export default {
	puppeteerOptions: {
		executablePath: "C:\\Program Files (x86)\\Google\\Chrome Dev\\Application\\chrome.exe"
	}
}

I've run into this problem on similar projects, so I've opened a PR on the chrome-launcher library to add detection for Beta and Dev channels.

LachlanArthur avatar May 09 '23 10:05 LachlanArthur

Make sure that you have Chrome installed and then in the same path you trigger the npx unlighthouse, do what @LachlanArthur has done.

It has worked for me

alex-alra-arteaga avatar May 09 '23 13:05 alex-alra-arteaga