Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot find module puppeteer #16

Closed
Tragio opened this issue Apr 21, 2022 · 9 comments · Fixed by #97
Closed

Cannot find module puppeteer #16

Tragio opened this issue Apr 21, 2022 · 9 comments · Fixed by #97

Comments

@Tragio
Copy link

Tragio commented Apr 21, 2022

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 🙏

@zuramai
Copy link

zuramai commented Apr 25, 2022

Same here

@harlan-zw
Copy link
Owner

harlan-zw commented May 9, 2022

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

@Tragio
Copy link
Author

Tragio commented May 9, 2022

@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

@harlan-zw
Copy link
Owner

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

@Tragio
Copy link
Author

Tragio commented May 9, 2022

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.

@lasfito
Copy link

lasfito commented Oct 7, 2022

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

@Tragio
Copy link
Author

Tragio commented Mar 2, 2023

@harlan-zw does this help?

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

@LachlanArthur
Copy link

LachlanArthur commented May 9, 2023

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.

@alex-alra-arteaga
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants