{"record":{"id":"5f7cbcff6621d211","repo":"mem0ai/mem0","slug":"the-aws-sdk-client-s3vectors-package-is-require","errorCode":null,"errorMessage":"The '@aws-sdk/client-s3vectors' package is required to use the S3 Vectors store. Install it with: npm install @aws-sdk/client-s3vectors","messagePattern":"The '@aws-sdk/client-s3vectors' package is required to use the S3 Vectors store\\. Install it with: npm install @aws-sdk/client-s3vectors","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"mem0-ts/src/oss/src/vector_stores/s3_vectors.ts","lineNumber":76,"sourceCode":"    }\n\n    this.config = config;\n    this.vectorBucketName = config.vectorBucketName;\n    this.collectionName = config.collectionName;\n    this.dimension = dimension;\n    this.distanceMetric = config.distanceMetric || \"cosine\";\n\n    void this.initialize().catch(console.error);\n  }\n\n  /**\n   * Lazily import the optional `@aws-sdk/client-s3vectors` peer so consumers\n   * who never use the S3 Vectors store don't need it installed.\n   */\n  private getSdk(): Promise<any> {\n    if (!this.sdkPromise) {\n      this.sdkPromise = import(\"@aws-sdk/client-s3vectors\").catch(() => {\n        throw new Error(\n          \"The '@aws-sdk/client-s3vectors' package is required to use the S3 Vectors store. Install it with: npm install @aws-sdk/client-s3vectors\",\n        );\n      });\n    }\n    return this.sdkPromise;\n  }\n\n  /** Lazily construct (or reuse) the S3 Vectors client. */\n  private async getClient(): Promise<S3VectorsClientLike> {\n    if (this.client) return this.client;\n    if (!this.clientPromise) {\n      this.clientPromise = this.createClient();\n    }\n    this.client = await this.clientPromise;\n    return this.client;\n  }\n\n  private async createClient(): Promise<S3VectorsClientLike> {","sourceCodeStart":58,"sourceCodeEnd":94,"githubUrl":"https://github.com/mem0ai/mem0/blob/001c235229be8795e3834520467bd0d661ed8f34/mem0-ts/src/oss/src/vector_stores/s3_vectors.ts#L58-L94","documentation":"@aws-sdk/client-s3vectors is an optional peer dependency, imported lazily so consumers not using the S3 Vectors store don't pay for it. If the import fails (package not installed), the store throws with the exact install command. This surfaces on the first store operation that needs the SDK, not at construction.","triggerScenarios":"Using S3Vectors without npm install @aws-sdk/client-s3vectors; a bundled deployment (Lambda layer, Docker image) where the optional dependency was tree-shaken or excluded from package.json installation; pnpm strict peer resolution skipping the optional package.","commonSituations":"CI installs with --omit=optional or production installs where the optional peer was never declared; monorepo hoisting issues; upgrading the store without re-reading the peer dependency list.","solutions":["npm install @aws-sdk/client-s3vectors (or pnpm add / yarn add) in the project using the S3 Vectors store","Verify the package resolves at runtime: node -e \"import('@aws-sdk/client-s3vectors').then(()=>console.log('ok'))\"","In bundled deployments, ensure the SDK is not marked external-and-absent — include it in the bundle or the image"],"exampleFix":"# before\nnpm install mem0ai  # s3 vectors unused dependency missing\n\n# after\nnpm install mem0ai @aws-sdk/client-s3vectors","handlingStrategy":"validation","validationCode":"async function assertS3VectorsSdk(): Promise<void> {\n  try { await import('@aws-sdk/client-s3vectors'); }\n  catch { throw new Error('Run: npm install @aws-sdk/client-s3vectors'); }\n}\nawait assertS3VectorsSdk();","typeGuard":null,"tryCatchPattern":"try { await s3vs.search(vec, {}); } catch (e) { if (e instanceof Error && e.message.includes('@aws-sdk/client-s3vectors')) { /* install dependency, redeploy */ } throw e; }","preventionTips":["Declare the SDK in dependencies (not merely hope the peer resolves) for any deployable using S3 Vectors","Smoke-test the dynamic import in CI for the environment that uses this store","Watch bundler configs that exclude optional peers from Lambda/Docker artifacts"],"tags":["s3-vectors","aws-sdk","dependency","installation","typescript"],"backgroundTag":null,"analyzedSha":"001c235229be8795e3834520467bd0d661ed8f34","analyzedAt":"2026-08-15T01:55:42.685Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}