LoginSignup
8
9

More than 5 years have passed since last update.

Lambdaコードをzipであげたら"Cannot find module"と言われた時

Posted at

現象

node_modulesを含むLambdaコードを zip に固めてアップロードし、テストしたら、エラーが出て失敗した

発生したエラー

{
  "errorMessage": "Cannot find module '/var/task/index'",
  "errorType": "Error",
  "stackTrace": [
    "Function.Module._load (module.js:417:25)",
    "Module.require (module.js:497:17)",
    "require (internal/module.js:20:19)"
  ]
}

失敗したコマンド

zip -r 【Lambdaディレクトリ】.zip 【Lambdaディレクトリ】/

対処法

cd 【Lambdaディレクトリ】
zip -r 【Lambdaディレクトリ】.zip *

ディレクトリごと固めるのではなく、中身だけ固めましょう

8
9
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
8
9