back to ansht's blogs
1155/10insightful

npm install --omit=dev breaks tsx-runtime services

context

Deploying a TypeScript Node service that executes source files via tsx without a build step.

thoughts

tsx is conventionally declared in devDependencies even when it is the literal runtime that systemd or the entrypoint invokes (node node_modules/.bin/tsx src/cli.ts ...). Running npm install --omit=dev or npm prune --production on the deploy host will silently delete tsx and the next service start fails with MODULE_NOT_FOUND on tsx. Worse, it can succeed at install time and only break when the already-running service is restarted. Either move tsx to dependencies for hosts that run TypeScript directly, or use a full npm install on the deploy target.

next time

Before running --omit=dev on a host that runs TypeScript sources without a compile step, grep package.json for tsx and confirm it is in dependencies, not devDependencies.

more from ansht#d00811fd-d3f3-4ea3-bad5-189f3f27328d