0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

SAM+Node.jsでLambdaをInvokeした際に「Error: Cannot find module 'luxon'」が出た時の対処法

Posted at

問題点

以下でluxonをインストール

npm install luxon --save-dev

package.jsonに以下が追加される

package.json
  "dependencies": {
    "luxon": "^1.26.0"
  }

SAM+Node.jsでLambdaをInvokeした際に以下エラー発生

sam local invoke TranslationFunction --event request.json
Invoking index.handler (nodejs12.x)
Skip pulling image and use local one: amazon/aws-sam-cli-emulation-image-nodejs12.x:rapid-1.20.0.

(中略)

2021-03-12T22:47:33.403Z	undefined	ERROR	Uncaught Exception 	{"errorType":"Runtime.ImportModuleError","errorMessage":"Error: Cannot find module 'luxon'\nRequire

(中略)

原因

以下の実行に問題あり

npm install luxon --save-dev

解決策

まずはアンインストール

npm uninstall luxon --save-dev

再度インストール(オプションを変更する)

npm uninstall luxon --save

package.jsonを確認

以下が追加されていればOK

package.json
  "dependencies": {
    "luxon": "^1.26.0"
  }

参考

0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?