Invalid ELF header

I get the following error when I try to load the pdfnet library on aws lambda

INFO Error: Error: /opt/nodejs/node_modules/@pdftron/pdfnet-node/lib/addon.node: invalid ELF header at Object.Module._extensions..node (internal/modules/cjs/loader.js:1144:18) at Module.load (internal/modules/cjs/loader.js:950:32) at Function.Module._load (internal/modules/cjs/loader.js:790:12) at Module.require (internal/modules/cjs/loader.js:974:19) at require (internal/modules/cjs/helpers.js:101:18) at Object.loadWorker (/opt/nodejs/node_modules/@pdftron/pdfnet-node/lib/pdfnet.js:40:357) at /opt/nodejs/node_modules/@pdftron/pdfnet-node/lib/pdfnet.js:1163:363 at new Promise (<anonymous>) at Object.t.preloadWorker (/opt/nodejs/node_modules/@pdftron/pdfnet-node/lib/pdfnet.js:1161:233) at Object.t.preloadPDFWorker (/opt/nodejs/node_modules/@pdftron/pdfnet-node/lib/pdfnet.js:1161:157) { code: 'ERR_DLOPEN_FAILED' }

nodejs version is 14.x
pdftron installed by nodejs version 14.x

does it not work in aws lambda nodejs evironment ?

thanks

1 Like

Hello, I’m Ron, an automated tech support bot :robot:

While you wait for one of our customer support representatives to get back to you, please check out some of these documentation pages:

Guides:APIs:Forums:

This is a native binary issue, not a NodeJS issue.

What is the exact architecture of your Linux lambda? x86_64? arm64?

Alternatively, here is someone who had similar issue and found it was due to copy error.

Facing a similar issue with PDFTron with AWS Lambda ran locally in my machine through AWS SAM

Error: {“code”:“ERR_DLOPEN_FAILED”}

Resources:
PDFTronUtilityFunction:
Type: AWS::Serverless::Function
Properties:
CodeUri: pdftron-app/
Handler: app.lambdaHandler
Runtime: nodejs16.x
Architectures:
- x86_64

As Ryan mentioned above, it’s a binary issue. Node modules need to be compiled for the target environment. If you’re supplying a .zip for the Lambda source code, and in that .zip is node modules compiled locally, it’s not going to work. See this post: