segment-boneyard / nightmare

A high-level browser automation library.
https://open.segment.com
19.55k stars 1.08k forks source link

Using nightmarejs in AWS Lambda functions #953

Closed ghost closed 7 years ago

ghost commented 7 years ago

Hi!

I am having some issue trying to use nightmare inside an AWS Lambda.

My code works great locally, but when I deploy (I use browserify to bundle my lambda package, otherwise it would be 150MB), I receive this error:

Electron failed to install correctly, please delete node_modules/electron and try installing again

Did you manage to run it on this environment? thanks

cheers

R

ajagnanan commented 7 years ago

I couldn't get it to deploy because of electron's file size. I tried going back pre version 2.0 (before electron is used), but it didn't work either for me. I was going to try other scrapers, this looked feasible: http://casperjs.org

Try this: https://github.com/narainsagar/node-casperjs-aws-lambda

ghost commented 7 years ago

thanks a lot @ajagnanan I will have a look into that, hope anyway that nightmare can be run somehow inside lambdas and that as solution is already out there :D thanks

schnerd commented 7 years ago

Building on @ajagnanan's answer, it's unlikely that nightmare can be used in lambda since the electron binary is over 130mb compressed, and lambda's maximum deployment package size is 50mb. Would be impressed if someone can find a way around this.

sopel commented 7 years ago

@schnerd - someone has found away around this: dimkir/nightmare-lambda-tutorial

While that is an impressive workaround indeed, if you are not too invested in nightmare, you might also want to check out graphcool/chromeless, which draws a lot of inspiration from nightmare, but has a native AWS Lambda story (refer to How is this different from NightmareJS, PhantomJS or Selenium? for details).

casesandberg commented 7 years ago

Looks like this is resolved. I am going to close this for now but feel free to open a new issue if you are still having problems.

iblessedi commented 4 years ago

It used to work. After upgrading Lambda to Node v10 (AWS forces us to do that) dimkir/nightmare-lambda-tutorial stopped working. We need another solution.