1
votes

I got Error: spawn EACCES error at the following line when I tried to execute this in aws lambda.

var zip = childProcess.spawn('zip', [
        '-r',
        job.destination.name,
        './'
    ], {
        cwd: temporaryDirectoryPath
    });

I have a binary file 'zip'.

Full error trace:

Error: spawn EACCES
at exports._errnoException (util.js:1018:11)
at ChildProcess.spawn (internal/child_process.js:319:11)
at Object.exports.spawn (child_process.js:378:9)
at createCompressedFile (/var/task/index.js:141:32)
at /var/task/node_modules/async/lib/async.js:718:13
at iterate (/var/task/node_modules/async/lib/async.js:262:13)
at /var/task/node_modules/async/lib/async.js:274:29
at /var/task/node_modules/async/lib/async.js:44:16
at /var/task/node_modules/async/lib/async.js:723:17
at /var/task/node_modules/async/lib/async.js:167:37
1
This is most likely caused by cwd : temporaryDirectoryPath, when the user your process is running as doesn't have access to temporaryDirectoryPath.robertklep
I create that directory in every instance with this line var mkdir = childProcess.spawn('mkdir', [ temporaryDirectoryPath ], { cwd: __dirname });NPCRNPCR
And temporaryDirectoryPath = path.join('/tmp', context.awsRequestId);NPCRNPCR
Do you check for errors when that directory is created? FWIW, you can use fs.mkdir instead of spawning a child process to call mkdir.robertklep
Yeah. I have a console.log for that. and the exit code is 0.NPCRNPCR

1 Answers

1
votes

Finally, it worked for me. So all errors like EACCES, ENOEN... has gone.

child_process.spawnSync('mybinary', [], {
  shell: true
})