Lee Maan
Lee Maan

Reputation: 719

Error: spawn EACCES in Node AWS Lambda function using child_process to call a binary file

I have this simplified code in a Node-based AWS Lambda function:

import { execFile } from 'child_process';
execFile('./node_modules/webp/bin/dwebp', ['./tmp/file.wepb', '-o', 
'./tmp/newFile.png'], (error, stdout, stderr) => {
  if (error) throw error;
});

As shown, I have a binary file in node_modules/webp/bin and I'm calling it with execFile to save an output in the folder ./tmp/ but I'm getting the error Error: spawn EACCES. Probably I'm not denied to access the folder ./tmp/ because my code is successfully writing files in it. I might be only denied to access to command dwebp itself. I don't know how to handle it. Hope you can help.

Upvotes: 0

Views: 1334

Answers (1)

daviscodesbugs
daviscodesbugs

Reputation: 707

Adding my comment as an answer since it seemed to be the solution to your problem.

Writing to the folder means you have write permissions. You still might be lacking execution permissions.

You can edit permissions within Node using the chmod from the fs module. Documentation can be found here.

Upvotes: 1

Related Questions