Search code examples
node.jsamazon-web-servicesaws-lambdaalexa-skills-kit

Cannot deploy a NodeJS AWS Lambda Function. Error at Object.fs.openSync


so until a few days ago I used to deploy my Node.JS AWS Lambda functions via a short and simple shell script, which worked perfectly fine.

Now I do not know why or what I have done different, but for some reason after every deploy of my lambda function I now get the following error, when invoking the function via Alexa:

19:47:58
module initialization error Error
module initialization error
Error

19:47:59
START RequestId: 596b2724-68f9-11e8-aaa7-d9ff3044ed9d Version: $LATEST
START RequestId: 596b2724-68f9-11e8-aaa7-d9ff3044ed9d Version: $LATEST

19:47:59
module initialization error: Error at Object.fs.openSync (fs.js:646:18) 
at Object.fs.readFileSync (fs.js:551:33) 
at Object.Module._extensions..js (module.js:662:20) 
at Module.load (module.js:565:32) 
at tryModuleLoad (module.js:505:12) 
at Function.Module._load (module.js:497:3) 
at Module.require (module.js:596:17) 
at require (internal/module.js:11:18)

module initialization error: Error
at Object.fs.openSync (fs.js:646:18)
at Object.fs.readFileSync (fs.js:551:33)
at Object.Module._extensions..js (module.js:662:20)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
at Module.require (module.js:596:17)
at require (internal/module.js:11:18)

19:47:59
END RequestId: 596b2724-68f9-11e8-aaa7-d9ff3044ed9d

19:47:59
REPORT RequestId: 596b2724-68f9-11e8-aaa7-d9ff3044ed9d  
Duration: 218.74 ms  Billed Duration: 300 ms 
Memory Size: 128 MB Max Memory Used: 20 MB

REPORT RequestId: 596b2724-68f9-11e8-aaa7-d9ff3044ed9d  
Duration: 218.74 ms Billed Duration: 300 ms 
Memory Size: 128 MB Max Memory Used: 20 MB  

Now here comes the part that really makes me clueless how I could solve this, (and it is probably something local on my Mac, I guess). If I download / export a previously working deployment package from my Lambda function and directly reupload the Zip file, it works.

If I unzip the file and rezip it again , I get the error

without me changing anything about the code. That is what makes me wonder if there is something wrong with the zipping on my mac or maybe the file system?

I am using Mac OSX High Sierra, Node 6.10 / 8.10 via nvm. The code on lambda runs with 6.10 and 8.10

Any suggestions appreciated :)

Edit: The last working commit was done on a windows PC... I am slightly worried whether the file system change somehow breaks the zipping / upload. I will try and have a deeper look into that.


Solution

  • Okay, only thing that was able to solve this, was going back to the last commit that I did from OSX and ignoring the last 3 commits that I did on windows.

    It looks like there were some path or encoding changes that were introduced by committing on windows which resolved in this error. Unfortunately I cannot see those in the commit diffs.

    So looking for differences between operating systems might be important here.