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?

APIGateWay+Expressで"TypeError: ee.on is not a function"エラーが起きた時の対処法

Posted at

経緯

【10分AWSハンズオン】ExpressをAWS Lambda+API Gatewayにデプロイするを参考にAWSLambda+Expressでルーティングをしていた。要約するとHTTP APIを作成して/{proxy+}で全てのエンドポイントをLambdaに流してExpressでルーティングしてます。実装が終わったので動かしたところ下記エラー。

2025-03-19T10:17:35.329Z	0d64597d-4515-4acc-bb33-b36701b066c3	ERROR	TypeError: ee.on is not a function
    at first (/var/task/node_modules/ee-first/index.js:43:10)
    at onSocket (/var/task/node_modules/on-finished/index.js:115:16)
    at attachFinishedListener (/var/task/node_modules/on-finished/index.js:120:5)
    at attachListener (/var/task/node_modules/on-finished/index.js:147:5)
    at onFinished (/var/task/node_modules/on-finished/index.js:53:3)
    at send (/var/task/node_modules/finalhandler/index.js:319:3)
    at /var/task/node_modules/finalhandler/index.js:135:5
    at /var/task/node_modules/express/lib/router/index.js:646:15
    at next (/var/task/node_modules/express/lib/router/index.js:265:14)
    at expressInit (/var/task/node_modules/express/lib/middleware/init.js:40:5)

調べても良い記事がヒットせず、かなり悩まされました。

解決策

いろいろ設定をいじっていたところ"ペイロード形式のバージョン"の項目ついて参考記事では言及がなかった。もしや参考記事が執筆された後に追加されたのではと思い推奨の2.0から1.0に変更。

スクリーンショット 2025-03-19 19.28.43.png

これで直りましたとさ。こんなトラップ推奨しないで...

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?