DEV Community

Discussion on: Generate a PDF in AWS Lambda with NodeJS and Puppeteer

Collapse
 
johnlealviva profile image
john-leal-viva

Hi - great article, but I am getting the following error: ERROR in ../../chrome-aws-lambda/build/puppeteer/lib/Browser.js.map 1:10
Module parse failed: Unexpected token (1:10)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See webpack.js.org/concepts#loaders

As it is a Webpack compilation error, do you have any suggestions?

Collapse
 
johnlealviva profile image
john-leal-viva

Do I need a typescript loader with my webpack?

Collapse
 
akirautio profile image
Aki Rautio

Thanks for the feedback :)

This certainly is webpack related issue and it's a bit hard to debug the issue without knowing the configuration. But the error message basically tells that you are trying handle the .map file with webpack. The map files are for debugging reason and they are not needed to be handled by webpack so there definitely is something regarding configuration.

Couple of points to check from webpack:

  1. Puppeteer should be only be imported server side so check that your build is only for server.
  2. You most likely can include the transpiling for node_modules in server side since the puppeteer has already been transpiled to javascript that most reasonably new nodeJs versions should understand.
Thread Thread
 
johnlealviva profile image
john-leal-viva

Interesting.
I attached an image of the full error message and an image of my Webpack.config file. It won't even let me deploy to lambda since there is the Webpack compilation error. There are 5 errors and each error is for a file in chrome-aws-lambda/source/puppeteer/lib/ directory.

Additionally, how might I put the transpiling on server side compared to how it would be now? That I am also unfamiliar with.

And thank you for the help. I'm an intern and junior in college and this is my first three weeks working in NodeJs!

Thread Thread
 
akirautio profile image
Aki Rautio

Hmm, could you try to reshare the images? For some reason they didn't end up to the post.

Also is there any specific reason you are using webpack for aws lambda? It might be that you don't even need it.

Thread Thread
 
johnlealviva profile image
john-leal-viva

Honestly you are right - I am trying with a clean slate and new service without Webpack to hopefully avoid this headache. I will let you know!

Thread Thread
 
johnlealviva profile image
john-leal-viva

I just want to say thank you because I have been trying to figure out how to make it work for the past day and a half. I just isolated it into its own service without Webpack and it worked in less than 10 minutes.

Thread Thread
 
akirautio profile image
Aki Rautio

Great to hear :)