1
1

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 5 years have passed since last update.

amazon lambda上で文字コード変換をする上でハマるたったひとつの罠

Posted at

開発環境とlambda環境の違い

  • npm installで処理するネイティブモジュールは環境に依存するため、lambdaについてはEC2上に同環境を作成して処理しないとうまく動かないことがある
  • 特にiconv!
# mac上だとうまくエンコードできるのに・・・(EC2上でネイティブモジュールを処理したものであればOK)
Error: Encoding not recognized: 'ISO-2022-JP' (searched as: 'iso2022jp')

最新のlambda環境をつくるためのAMI

余談

  • nodemalilerでiso-2022-jpがうまく扱えない記事を読みiconvを入れたにも関わらず、うまく動かない一因がおそらくこれ
  • 入れただけでうまく動かない場合はmimelibのデコードも合わせて利用しましょう
1
1
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
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?