BlogNode.js

Error: Cannot find module 'tsx' when the app starts How to fix it.

Your app builds and then fails to start because a package its start command needs was removed with the dev dependencies.

How the Agent API works
What you see
Your app built successfully but never started listening on port 3000.

We started it with: npm run start

Your app printed this before it exited:

  Error: Cannot find module 'tsx'
  • What it meansA start-time package is missing
  • Fix oneMove it to dependencies
  • Fix twoCompile in the build step
  • Common culpritstsx, ts-node, nodemon

What it means

Antideploy installs all your packages for the build, including development packages, then removes the development ones from the image your app runs in. If your start script uses a package that is only in devDependencies, it is gone by the time the app starts.

How to fix it

Move it to dependencies. If the app needs the package at runtime, such as tsx or ts-node to run TypeScript directly, list it under dependencies and commit the lock file.

Or compile in the build step. Add a build script that compiles your code, and make start run the compiled output with plain node, for example node dist/server.js. Then the development tools are only needed for the build.

package.json
{
  "scripts": {
    "build": "tsc",
    "start": "node dist/server.js"
  }
}

Which packages are affected

  • TypeScript runners such as tsx and ts-node
  • Reload tools such as nodemon
  • Any package your start script or your code imports at runtime but lists only as a development dependency

01Questions

Start-time module questions, answered.

Anything else? Write to us and a person answers.

support@antideploy.com
Why does it work on my machine?

Locally, npm install installs development packages too, so the start script finds them.

Is the same true for build tools?

No. Build tools can stay in devDependencies, because the build installs them. Only what runs when the app starts must be in dependencies.

Does this failed deploy cost anything?

No. Failed deploys never count against your plan.

Deploy something. Start with one sentence.

Paste one sentence into your coding agent, click Approve once, and get a live link. No card, no trial clock.

Start from GitHub or a folder
Prompt copied Paste it into Claude Code, Codex or Cursor and press Enter.