aws-lambda Cannot find module

前端 未结 12 718
野性不改
野性不改 2020-12-06 04:20

I keep getting this error in the aws-lambda console when uploading code from a zip file. I have tried uploading other zip files and they work correctly. The .js file is name

12条回答
  •  再見小時候
    2020-12-06 05:13

    I had this problem on a custom module I had built that was in the node_modules dir. Everything ran fine in testing on my Win10 machine, but when uploaded I kept getting that same "Cannot find module 'modulename'" error.

    It turns out that I had a mismatch; here's the package.json line from the module that couldn't be found:

    "main": "./build/modulename.js",
    

    and here's the actual filename:

    Modulename.js
    

    Case-sensitive; Windows isn't, linux (and thus AWS) is.

提交回复
热议问题