saltyshiomix / nextron

⚡ Next.js + Electron ⚡
https://npm.im/nextron
MIT License
3.97k stars 229 forks source link

Can't resolve 'ws' in "puppeteer-core/lib" #65

Open vsvanshi opened 4 years ago

vsvanshi commented 4 years ago

Hi Everyone, I am opening this issue here, after spending long time on the internet to resolve the related issue but no luck.

THE ISSUE: I am running an electron app with an example template of material ui and javascript. Everything is working fine, but when I install the "puppeteer-core" library (version 2.0.0) and import it like

import puppeteer from "puppeteer-core";

I start getting the following error

Screenshot 2020-01-06 at 3 27 58 PM

Ofcourse then I started looking at SO and Google for this error and the "resolution" that everyone is suggesting is to use the following setting for webpack.config.js file

const config = { // ... externals: { puppeteer: 'require("puppeteer")', // ... }, };

Since nextron is based on next js, the place that I could find to put this setting was in 'next.config.js' So I put the following code in it

... config.externals = { puppeteer :'require("puppeteer")' } ... return config;

But when I do this, A very strange error starts coming up.

Screenshot 2020-01-06 at 3 32 53 PM

I am really not sure, what is going on here.

It would be really helpful if someone can just tell me what is going on, and how to resolve this. Thanks in advance

lacymorrow commented 4 years ago

Are you still looking for help with this @vsvanshi?

vsvanshi commented 4 years ago

Yes, please @lacymorrow. I would definitely like to know what could have been done to prevent this error.

However for any user looking for a temporary solution, I had to leave nextron and proceed with "electron-webpack".

lacymorrow commented 4 years ago

Can you explain what you are trying to achieve with puppeteer inside electron?

On Tue, May 26, 2020 at 3:36 AM vsvanshi notifications@github.com wrote:

Yes, please @lacymorrow https://github.com/lacymorrow. I would definitely like to know what could have been done to prevent this error.

However for any user looking for a temporary solution, I had to leave nextron and proceed with "electron-webpack".

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/saltyshiomix/nextron/issues/65#issuecomment-633946019, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAKAERNZBYQOQ5COLEZFOH3RTOLSDANCNFSM4KDCFXVQ .

vsvanshi commented 4 years ago

yes Sure @lacymorrow i am making a desktop application which enables a user to open a specific website using puppeteer and and run a testing script on that website and see it all in action

lacymorrow commented 4 years ago

Thanks @vsvanshi, I may have some time in the next couple of weeks to look into this

vsvanshi commented 2 years ago

@lacymorrow did you get a chance to look at this?

philipmckenna commented 1 year ago

@vsvanshi I ran into a similar issue, however I was able to resolve it by adding to the externals rather than overriding them.

... config.externals = [...config.externals, {whatever you wish to add}] ...

Psycokwet commented 1 year ago

Hello there ! I tried to look into the use of puppeteer within an electron app, did you try https://www.npmjs.com/package/puppeteer-in-electron this package ?

I did not yet made it work, but I think that's a better road so far. I might try to look into it further and work on an example with it when I can.

Let me know if there is any update about it !