pnpm-export
v0.2.1
Published
Export one package from a pnpm workspace into an npm-installable directory.
Downloads
283
Readme
pnpm-export
Export one package from a pnpm workspace into a self-contained directory that
installs with plain npm. Local workspace: dependencies come along, all
specifiers are rewritten to npm-compatible ones, and package-lock.json is
built from pnpm-lock.yaml.
npx pnpm-export --cwd packages/api --output /tmp/api
cd /tmp/api
npm installvs pnpm pack / pnpm deploy
pnpm packtarballs a single package and drops its workspace dependencies.pnpm deployships a tree but keeps pnpm-specific behavior.pnpm-exportrewritesworkspace:deps tofile:links and resolvescatalog:references, so the output runs on plain npm.
Use cases
- Deploy a single service from a pnpm monorepo to AWS Lambda, Google App
Engine, Cloud Run, Cloudflare Workers, Azure Functions, Heroku, Vercel,
Netlify, Render, Fly.io, or Railway — anywhere the build step runs
npm installand chokes onworkspace:*orcatalog:specifiers. - Slim Docker images — copy one self-contained directory into the container instead of the whole monorepo, with no pnpm needed at build or runtime.
- CI artifact handoff — produce the export in one job, then install it in another job, machine, or downstream pipeline that doesn't have pnpm.
- Vendor or publish a package without exposing pnpm-only specifiers —
workspace:deps become realfile:links,catalog:refs resolve to concrete versions, andpackage-lock.jsonis generated frompnpm-lock.yamlfor reproducible installs. - Air-gapped or offline builds — the output is one self-contained directory plus a lockfile, easy to review, ship, or mirror.
Flags
Usage: pnpm-export [options]
Export one package from a pnpm workspace for npm install.
Options:
-v, --version output the version number
-C, --cwd <dir> source package directory
-o, --output <dir> output directory
-D, --dev-dependencies Follow "workspace:" devDependencies (default:
true)
--no-dev-dependencies Skip "workspace:" devDependencies
-P, --peer-dependencies Follow "workspace:" peerDependencies (default:
true)
--no-peer-dependencies Skip "workspace:" peerDependencies
-O, --optional-dependencies Follow "workspace:" optionalDependencies
(default: true)
--no-optional-dependencies Skip "workspace:" optionalDependencies
--patch-dependencies <mode> patch dependency handling: ignore | warning |
try-replace (default: "try-replace")
--clean wipe output directory contents before writing
(default: false)
--lockfile emit package-lock.json (experimental) (default:
false)
--dry-run print planned actions without writing (default:
false)
--silent suppress non-error output (default: false)
-h, --help display help for commandProgrammatic API
import { App, Config, makeDependencies, pnpmExport } from 'pnpm-export';
const config = new Config({
options: {
cwd: 'packages/api',
output: '/tmp/api',
clean: true,
},
});
const deps = makeDependencies({ config });
const app = new App({ deps });
await pnpmExport(app);License
Licensed under MIT.
