Amazon Web Services · infra · fg-0177

Lambda fails with Cannot find module 'aws-sdk' after moving to a newer Node.js runtime

If you see Runtime.ImportModuleError: Error: Cannot find module 'aws-sdk', the cause and the fix for Amazon Web Services are below, last verified 2026-10-15.

Verified Oct 2026trust 50/100
Symptom
Runtime.ImportModuleError: Error: Cannot find module 'aws-sdk'Code that ran on nodejs16.x breaks right after switching the runtimerequire('aws-sdk') works locally but not in the deployed function
Cause
Every supported Lambda Node.js runtime ships only SDK for JavaScript v3, not v2. Code that relied on the runtime providing aws-sdk v2 has nothing to load.
Fix
Port the calls to the modular v3 clients and bundle the clients you use in the deployment package rather than relying on the runtime copy.
Apply
npm install @aws-sdk/client-s3 // before: const AWS = require('aws-sdk'); new AWS.S3().getObject(p).promise() import { S3Client, GetObjectCommand } from '@aws-sdk/client-s3'; const s3 = new S3Client({}); const out = await s3.send(new GetObjectCommand(p));
Affected
Lambda nodejs18.x and every later Node.js runtime (currently nodejs22.x, nodejs24.x, nodejs26.x)
Sources

Last verified 2026-10-15 · Confirmed by 0 builders

Related traps

Have your agent know this before it fails

$ /plugin marketplace add getfootgun/footgun
$ /plugin install footgun@footgun