Amazon Web Services · infra · fg-0177
Lambda fails with Cannot find module 'aws-sdk' after moving to a newer Node.js runtime
Runtime.ImportModuleError: Error: Cannot find module 'aws-sdk'
Verified 2026-10-15 · Confirmed by 0 builders · Trust 50/100
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));Affects: Lambda nodejs18.x and every later Node.js runtime (currently nodejs22.x, nodejs24.x, nodejs26.x)
Sources
- https://docs.aws.amazon.com/lambda/latest/dg/lambda-nodejs.html
- https://docs.aws.amazon.com/lambda/latest/dg/nodejs-handler.html
Have your agent know this before it fails
claude mcp add --transport http footgun https://getfootgun.com/api/mcp