I'am deploying lambda function from my office where i have ubuntu operating system. when i deploy my serverless code its works fine, i can access the lambda api without any problem . but same code when i deploy at my home machine where i have windows operating system there it showing error "module initialization error" at the time of accessing the lambda api ("Note- There is no issues while deploying it, issue comes when i access the lambda API after deploying it from windows machine").
I debug the issue and i found that the issue is related with "bcrypt" Package. and in the logs i saw that, at the time when the code execution reaches to the file where i imported the "bcrypt" module it throws error. I don't know why it showing two different behavior on 2 different operating system for bcrypt only.
"dependencies": {
"@serverless/fdk": "^0.7.1",
"bcrypt": "^3.0.6",
"jsonwebtoken": "^8.5.1",
"mysql": "^2.17.1",
"serverless-http": "^2.0.2"
logs for myOwnFunction
module initialization error
Error
2019-06-08 09:25:06.043 (+05:30) 33f9015c-c9f0-43a5-8c4a-1fc617ad955d inside OwnerModel
In my code when code execution reaches at the below line
import bcrypt from 'bcrypt';
It shows module initialization error
I expect to execute the lambda api even if it is deployed with the help of windows machine.
You will need to compile the bcrypt
module on Amazon Linux with specific NodeJS version then zip and deploy it.
Alternatively, I would suggest use bcryptjs