LPM-cli

lpm exec

Run a JS or TS file directly with runtime auto-detection.

lpm exec <file> [-- args...]

Runs a single JavaScript or TypeScript file. .js / .mjs / .cjs always go through node; .ts / .tsx / .mts / .cts probe the same PATH lpm exec will actually use and pick the first compatible TypeScript runtime — see How runtime is picked below.

Useful for one-off scripts (scripts/seed.ts, tools/migrate.js) without adding a scripts entry to package.json.

Human progress goes to stderr and names the selected runtime before the file starts:

 Executing scripts/seed.ts with Node.js v22.12.0
 Done · exited 0 in 412ms

Examples

lpm exec scripts/seed.ts
lpm exec scripts/migrate.js
lpm exec scripts/seed.ts -- --env=staging      # forward args to the script
lpm exec src/cli.ts arg1 arg2                  # bare trailing args also work

How runtime is picked

ExtensionRuntime
.js, .mjs, .cjsnode — direct spawn, no shell
.ts, .tsx, .mts, .ctsFirst compatible runtime on the effective exec PATH: Node ≥23.6 (native TypeScript) → Node ≥22.6 (node --experimental-strip-types) → project-local tsxnpx tsx

The effective PATH includes project node_modules/.bin, any matching managed Node that LPM resolved for the project, and then your existing system PATH.

If lpm exec falls back to npx tsx, it prints a warning because the first run may download tsx from npm.

Environment loading

lpm exec loads the project's env files before spawn. --no-env-check skips env-schema validation only; it does not disable env loading.

Argument forwarding

Anything after the file is forwarded to it. -- is optional but useful when you want to pass args that look like LPM flags:

lpm exec scripts/seed.ts -- --verbose --env=prod

Flags

FlagEffect
--no-env-checkSkip env-var schema validation before execution

Plus the global flags.

See also

  • lpm run — run named scripts from package.json
  • lpm dlx — run a binary from a registry package without installing it
  • lpm dev — full dev server with HTTPS, tunnel, services