realcoloride / node_characterai

Unofficial Character AI wrapper for node.
https://beta.character.ai/
341 stars 72 forks source link

Cannot find module 'puppeteer-extra-plugin-stealth/evasions/chrome.app' in deployment #150

Closed IqroNegoro closed 4 months ago

IqroNegoro commented 7 months ago

First, thx for make this package, its amazing! i have romantic chat with my waifu, indeed in local development, but when I deploy it to hosting (like vercel / netlify), the package cannot find module 'puppeteer-extra-plugin-stealth'. i have try to including all or trying the solution in here, here, and here. or

Error :

A  plugin listed 'puppeteer-extra-plugin-stealth/evasions/chrome.app' as dependency, which is currently missing. Please install it:

yarn add puppeteer-extra-plugin-stealth

Note: You don't need to require the plugin yourself, unless you want to modify it's default settings.

its seems that puppeteer-extra-plugin-stealth not including all needed dependencies, or i missing something?, I using npm

SetroZ commented 6 months ago

did you figure anything out?

IqroNegoro commented 6 months ago

did you figure anything out?

maybe vercel and netlify is cannot deploying puppeteer because puppeteer size exceed vercel / netlify aws lambda function (at my case puppeteer is 62mb), because aws lambda cannot serve app size that exceed 50mb, seems that they stop working because it, but i doubtly this answer after surfing at internet. even this is the most reasonable answer, so you must deploy your API at dedicated server node js instead.

and if deploying at dedicated server idc how to make two or more user can chat to two or more character in same time because it must make new instance of CharacterAi, instead a function like chat('characterId', 'message')

SetroZ commented 6 months ago

Well, I was able to deploy on aws lambda. I used a layer to store @sparticuz/chromium , puppeteer-core,puppeteer-extra and puppeteer-extra-stealth plugin and it finally worked! I guess it is some bundling issue

IqroNegoro commented 6 months ago

Well, I was able to deploy on aws lambda. I used a layer to store @sparticuz/chromium , puppeteer-core,puppeteer-extra and puppeteer-extra-stealth plugin and it finally worked! I guess it is some bundling issue

not vercel / netlify? maybe because they is free, there is a limit that they set for max bundling for their aws lambda, instead size for real aws lambda is not max to 50mb, can i know what do you use? or somehow to make it work?

cokealmonacid commented 6 months ago

Hey! any news with this issue? been struggling with the same problem for a few days

IqroNegoro commented 6 months ago

Hey! any news with this issue? been struggling with the same problem for a few days

idk, i can't make it work until now in netlify / vercel... but i haven't tried it in dedicated server

SetroZ commented 6 months ago

Well, I was able to deploy on aws lambda. I used a layer to store @sparticuz/chromium , puppeteer-core,puppeteer-extra and puppeteer-extra-stealth plugin and it finally worked! I guess it is some bundling issue

not vercel / netlify? maybe because they is free, there is a limit that they set for max bundling for their aws lambda, instead size for real aws lambda is not max to 50mb, can i know what do you use? or somehow to make it work?

I used this

IqroNegoro commented 6 months ago

Well, I was able to deploy on aws lambda. I used a layer to store @sparticuz/chromium , puppeteer-core,puppeteer-extra and puppeteer-extra-stealth plugin and it finally worked! I guess it is some bundling issue

not vercel / netlify? maybe because they is free, there is a limit that they set for max bundling for their aws lambda, instead size for real aws lambda is not max to 50mb, can i know what do you use? or somehow to make it work?

I used this

are you forking, layering it with that and create own API in nodejs? i wanna try it later

realcoloride commented 6 months ago

Hello, sorry for the late response. I do not know why this is causing to all of you. Perhaps try installing it on a local machine and then copying the missing files.

Cheers.

IqroNegoro commented 6 months ago

Hello, sorry for the late response. I do not know why this is causing to all of you. Perhaps try installing it on a local machine and then copying the missing files.

Cheers.

at local machine is all good, nothing wrong, but just not work if i deployed it at netlify (using nuxt server) or in vercel (like simple API) with this error

Cannot find module 'puppeteer-extra-plugin-stealth/evasions/chrome.app
sivertheisholt commented 6 months ago

Are you using webpack? I have a similar problem where webpack doesn't play nice with puppeteer using CommonJS. Using ES module fixed my problems.

IqroNegoro commented 6 months ago

Are you using webpack? I have a similar problem where webpack doesn't play nice with puppeteer using CommonJS. Using ES module fixed my problems.

I used vite. Then you can use ES instead. If it work then good

sivertheisholt commented 6 months ago

Are you using webpack? I have a similar problem where webpack doesn't play nice with puppeteer using CommonJS. Using ES module fixed my problems.

I used vite. Then you can use ES instead. If it work then good

I havent used vite before so sorry if im on the wrong track here, but im guessing it builds on the same principles as webpack.

Is there a way to specify externals? As I had todo that with webpack:

externals: {
   "puppeteer": "puppeteer",
   "puppeteer-extra": "puppeteer-extra",
   "puppeteer-extra-plugin-stealth": "puppeteer-extra-plugin-stealth",
},

Webpack describes externals like this:

Specify dependencies that shouldn't be resolved by webpack, but should become dependencies of the resulting bundle.

IqroNegoro commented 6 months ago

Are you using webpack? I have a similar problem where webpack doesn't play nice with puppeteer using CommonJS. Using ES module fixed my problems.

I used vite. Then you can use ES instead. If it work then good

I havent used vite before so sorry if im on the wrong track here, but im guessing it builds on the same principles as webpack.

Is there a way to specify externals? As I had todo that with webpack:

externals: {
   "puppeteer": "puppeteer",
   "puppeteer-extra": "puppeteer-extra",
   "puppeteer-extra-plugin-stealth": "puppeteer-extra-plugin-stealth",
},

Webpack describes externals like this:

Specify dependencies that shouldn't be resolved by webpack, but should become dependencies of the resulting bundle.

me neither haven't try webpack lol.

CommonJS is old way to 'code' now (maybe), as i say, u can use ES if it work, maybe the problem is not bundling some 'dissapear package' at build process (it worked when i build the app) . but the hosted server instead

IqroNegoro commented 4 months ago

For someone who looking for the answer, the answer is ... idk, but there is a reason why you cannot deploy it at serverless (edge environment or etc) like netlify or vercel.

limit size for their aws 50mb is cannot make it up for puppeteer to run

if you use puppeteer-core and hosted the chromium, maybe it can... but i don't have try it yet try to host it in server instead.

feel free to re open if you have a solution

Joss-ZZ commented 4 months ago

Are you using webpack? I have a similar problem where webpack doesn't play nice with puppeteer using CommonJS. Using ES module fixed my problems.

I used vite. Then you can use ES instead. If it work then good

I havent used vite before so sorry if im on the wrong track here, but im guessing it builds on the same principles as webpack.

Is there a way to specify externals? As I had todo that with webpack:

externals: {
   "puppeteer": "puppeteer",
   "puppeteer-extra": "puppeteer-extra",
   "puppeteer-extra-plugin-stealth": "puppeteer-extra-plugin-stealth",
},

Webpack describes externals like this:

Specify dependencies that shouldn't be resolved by webpack, but should become dependencies of the resulting bundle.

This worked for me, thank you very much