I did some research and it looks like it’s due to the fact that I npm installed it on a macOS machine (my development machine) and deployed it to Lambda, which is Unix-based. More info here:
Is there a way around this issue? I could try to build it on Linux and copy-paste the module files into my dev environment, but then my local environment would not work properly.
I had the same problem with the node_expat module. After failing to come up with an elegant solution I decided to keep both versions (mac compiled and linux compiled) in my node_modules directory (e.g. node_expat.mac and node_expat.linux). Before deploying my function I ran a script to rename the linux version to the proper filename and deployed.
If you’re using native NPM’s you need to provide a version compiled for Lambda (i.e. using the correct AWS AMI) when you upload your node_modules folder. If you don’t it won’t run. It might worth looking into using CI/CD to deploy or adding a deploy script inside your package.json so that you always have a consistent deployment experience.