- 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