{"id":15445,"library":"lerna-to-lambda","title":"Lerna to Lambda Bundler","description":"lerna-to-lambda (l2l) is a specialized utility designed for developers working with Lerna monorepos who need to deploy individual packages as AWS Lambda functions. At version 0.3.1, this tool facilitates the creation of compact, standalone deployment archives by intelligently bundling a specific monorepo package with only its necessary dependencies. It resolves the common challenge of dealing with hoisted `node_modules` in Lerna projects by copying direct and recursive subdependencies into a single `node_modules` structure within the output directory. A key differentiator is its ability to correctly handle both external npm packages and internal, inter-dependent monorepo packages, ensuring a self-contained runtime environment for Lambda. By default, it excludes `aws-sdk`, assuming it's provided by the Lambda runtime. While a powerful bundling solution, it is not a package manager itself; users must ensure all dependencies are installed via `yarn` or `npm` prior to execution. Its release cadence is likely feature-driven given its current version number.","status":"active","version":"0.3.1","language":"javascript","source_language":"en","source_url":"https://github.com/lafiosca/lerna-to-lambda","tags":["javascript","typescript"],"install":[{"cmd":"npm install lerna-to-lambda","lang":"bash","label":"npm"},{"cmd":"yarn add lerna-to-lambda","lang":"bash","label":"yarn"},{"cmd":"pnpm add lerna-to-lambda","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"This package is designed as a command-line interface (CLI) tool for bundling, not for programmatic JavaScript imports. Execute `l2l` via `npx`, `yarn`, or `npm` scripts.","wrong":"import { l2l } from 'lerna-to-lambda'","symbol":"l2l (CLI command)","correct":"npx l2l -i build -o lambda"},{"note":"While `lerna-to-lambda` is primarily a CLI, its TypeScript declarations may expose types like `Options` for programmatic configuration or validation when used in a TypeScript project.","wrong":"import { Options } from 'lerna-to-lambda';","symbol":"Options (type)","correct":"import type { Options } from 'lerna-to-lambda';"},{"note":"As a CLI-focused package, `lerna-to-lambda` does not provide a default export for direct programmatic use.","wrong":"import l2l from 'lerna-to-lambda'","symbol":"(No default export)","correct":"// No default export from 'lerna-to-lambda'"}],"quickstart":{"code":"yarn add -W --dev lerna-to-lambda\n\n// In package.json scripts for a Lerna package:\n\"scripts\": {\n  \"clean\": \"rimraf build lambda\",\n  \"compile\": \"tsc -p tsconfig.build.json\",\n  \"package\": \"l2l -i build -o lambda\",\n  \"build\": \"yarn run clean && yarn run compile && yarn run package\"\n}","lang":"typescript","description":"Demonstrates adding `lerna-to-lambda` as a dev dependency and integrating its `l2l` command into a TypeScript project's build workflow to create Lambda deployment packages."},"warnings":[{"fix":"Always run `yarn install` or `npm install` in your monorepo root to ensure `node_modules` is populated before invoking `l2l`.","message":"lerna-to-lambda is not a package manager; it does not install or verify package versions. Users must ensure all dependencies (both internal monorepo and external npm) are correctly installed via `yarn` or `npm` *before* running `l2l`.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Thoroughly test bundled Lambda functions after running `l2l`. Pay close attention to packages that might be sensitive to their location or to multiple versions of the same dependency. Consider using a `nohoist` strategy for problematic packages in Lerna if issues persist.","message":"The dependency topology within the bundled `node_modules` can shift. Lerna-hoisted dependencies may be 'unhoisted' and moved into sub-`node_modules` directories within the package bundle. This rearrangement can potentially lead to unexpected behavior or break certain packages that rely on specific `node_modules` structures.","severity":"breaking","affected_versions":">=0.1.0"},{"fix":"If `aws-sdk` is explicitly needed in your bundle, review `l2l` CLI options (e.g., `--no-omit-aws-sdk`) to include it. Verify the Lambda runtime's `aws-sdk` version compatibility with your function's requirements.","message":"By default, `l2l` omits the `aws-sdk` dependency and its subdependencies from the bundle. This assumes `aws-sdk` is provided by the target AWS Lambda runtime environment. If your Lambda environment does not provide `aws-sdk` or requires a specific version not implicitly available, your function will fail.","severity":"gotcha","affected_versions":">=0.1.0"}],"env_vars":null,"last_verified":"2026-04-21T00:00:00.000Z","next_check":"2026-07-20T00:00:00.000Z","problems":[{"fix":"Ensure 'my-internal-monorepo-package' is listed in the `package.json` dependencies of the target Lambda package. Verify that Lerna has correctly linked it before running `l2l`.","cause":"The internal Lerna package dependency was not correctly identified or copied into the Lambda bundle's `node_modules`.","error":"Error: Cannot find module 'my-internal-monorepo-package'"},{"fix":"Run `yarn install` or `npm install` in your monorepo root to ensure all external dependencies are installed. Confirm `l2l` is running *after* this installation step in your build process.","cause":"An external npm package required by your Lambda function was not installed or bundled correctly before deployment.","error":"Runtime.ImportModuleError: Error: Cannot find module 'some-external-npm-dependency'"},{"fix":"Ensure the user executing `l2l` has write permissions to the specified output directory. You might need to adjust directory permissions or run the command with elevated privileges (e.g., `sudo`, or correct user setup in CI/CD).","cause":"The `l2l` command does not have sufficient permissions to create the output directory or write files within it.","error":"EACCES: permission denied, mkdir '/path/to/output'"}],"ecosystem":"npm"}