{"id":25852,"library":"lambda-build","title":"lambda-build","description":"Bundle TypeScript/JavaScript Node.js Lambda handlers into a deployable zip using esbuild. Current version: 1.0.6. Provides CLI commands (`archive`, `upload`) and programmatic API (`build`, `buildAndUpload`). Supports custom entry files, excluding external modules (e.g., layers), and generating esbuild metafiles for bundle analysis. Differentiates from similar tools by focusing solely on Lambda deployment with zero-config defaults and AWS CLI integration. Ships with TypeScript declarations. Lightweight alternative to serverless-webpack or AWS SAM.","status":"active","version":"1.0.6","language":"javascript","source_language":"en","source_url":null,"tags":["javascript","lambda","serverless","esbuild","typescript"],"install":[{"cmd":"npm install lambda-build","lang":"bash","label":"npm"},{"cmd":"yarn add lambda-build","lang":"bash","label":"yarn"},{"cmd":"pnpm add lambda-build","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Package exports named exports; default import does not exist. Works in both ESM and CJS, but ESM import is preferred for TypeScript.","wrong":"const build = require('lambda-build').build","symbol":"build","correct":"import { build } from 'lambda-build'"},{"note":"Correct in CJS but ESM import is recommended when using TypeScript or ES modules.","wrong":"const { buildAndUpload } = require('lambda-build')","symbol":"buildAndUpload","correct":"import { buildAndUpload } from 'lambda-build'"},{"note":"Package only exports named exports. Doing a default import will result in undefined.","wrong":"import lambdaBuild from 'lambda-build'","symbol":"default import (does not exist)","correct":"import { build } from 'lambda-build'"}],"quickstart":{"code":"import { build } from 'lambda-build';\n\nasync function quickstart() {\n  const result = await build({\n    entry: 'src/handler.ts',\n    external: ['aws-sdk'],\n    metafile: true,\n  });\n  console.log('Archive size:', result.archiveSize);\n  // result.archive is a Buffer of the zip\n}\n\nquickstart().catch(console.error);","lang":"typescript","description":"Shows programmatic usage: bundle a TypeScript Lambda handler and create a zip archive with metafile."},"warnings":[{"fix":"Ensure AWS CLI is set up via `aws configure` before using `upload`.","message":"The `upload` command requires the AWS CLI to be installed and configured locally.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Verify that excluded dependencies are present as layers or included in the Lambda runtime.","message":"External modules declared via `-x` or `external` option must be available in the Lambda runtime environment (e.g., via layers or Lambda provided SDK).","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"None.","message":"No deprecated features known at this version.","severity":"deprecated","affected_versions":">=0.0.0"},{"fix":"Update to use esbuild options; see documentation for changes.","message":"Major version 1.x introduced esbuild as the bundler. If migrating from a previous major version that used a different bundler, configuration may differ.","severity":"breaking","affected_versions":"<1.0.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Install esbuild as a dev dependency: `npm i -D esbuild`","cause":"lambda-build depends on esbuild but does not automatically install it.","error":"Error: esbuild is not installed. Please install it manually: npm i -D esbuild"},{"fix":"Either add 'aws-sdk' to external array only if you have it in a layer, or bundle it by removing it from external.","cause":"AWS SDK is excluded by default but not provided in the runtime layer.","error":"Error: Cannot find module 'aws-sdk'"},{"fix":"Pass an `entry` option pointing to your handler file, e.g., `entry: 'src/handler.ts'`.","cause":"You called `build` without specifying an entry file.","error":"Error: The 'entry' option is required."},{"fix":"Use `-e` to specify a custom entry file, or create a default index file.","cause":"The default entry file (index.js or index.ts) does not exist in the current directory.","error":"Error: ENOENT: no such file or directory, open 'src/index.ts'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}