:wave: My colleague is having problems with `pdfki...
# sst
b
👋 My colleague is having problems with
pdfkit
library and esbuild - has anyone had similar problems and solution for this? Thanks!
Copy code
`Error: ENOENT: no such file or directory, open '/Users/.../pms-integrations-v2/services/hsk/.build/src/cron/data.trie'
https://github.com/foliojs/pdfkit/issues/990 https://stackoverflow.com/questions/67234055/pdfkit-on-js-ts-lambda-with-cdk-error-enoent-no-such-file-or-directory-open
r
How're you bundling pdfkit? Have you tried adding it to the nodeModules property of the bundle to remove it from esbuild bundling and force its install?
b
He just texted me this, the nodeModules approach seems to work! “Both approaches work! 
pdfmake
 and 
chrome-aws-lambda
  with 
puppeteer
 . Issue with both was that I was trying to have code in packages/common, once I moved pdf generator service to services/hsk it worked. The second one also required adding 
chrome-aws-lambda
  to bundle externalModules and  
'arn:aws:lambda:eu-central-1:764866452798:layer:chrome-aws-lambda:25'
 to layers. I will go with pdfmake since we already have it in other project. (edited)”
f
Thanks @Ross Coundon!
b
Oh yeah thanks @Ross Coundon, cant believe I forgot to say it :)))
r
Don't worry, I got a thanks from your excited tone 😄
b
I remember well your name and your 2 accounts! If you remember I had issue with aws-sdk and it being not found in lambda after set in externalModules in the Serverless Community slack! The issue was actuallly that I had
NODE_PATH=./src
somehow set in env which was messing things up! 😄
r
I've had something similar happen to me before where a rather hungry env var set up script was copying NODE_ENV values into a lambda and confusing the hell out of me
b
It was pissing me off few weeks until I finally set and went through each line/env and realized this thing existing and being only difference between 2 projects 😄
r
Hi @Branko Gvoka @Ross Coundon @Frank, I faced similar issue with
pdfmake
but I am not sure how to do @Ross Coundon’s suggestion to bundle it and add it to nodeModules property. Is it using
serverless-bundle
from the this link?
r
Are you using SST? If so, it's called nodeModules in the bundle property of the Function Props, or alternatively via defaultFunctionProps
e.g.
Copy code
export default function main(app: <http://sst.App|sst.App>): void {
  app.setDefaultFunctionProps({
    bundle: {
      nodeModules: [
        'pdfmake'
      ]
  })
...
}
r
@Ross Coundon Thank you very much. That works! 🙇 🎉
r
Great stuff đŸ‘đŸ»