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

URL: https://antideploy.com/blog/error-cannot-find-module-when-the-app-starts

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

**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'
```

## At a glance

- **What it means**: A start-time package is missing
- **Fix one**: Move it to dependencies
- **Fix two**: Compile in the build step
- **Common culprits**: tsx, ts-node, nodemon

Published 7 October 2026. Facts checked 7 October 2026. 1 min read.

## 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

## Start-time module questions, answered.

Anything else? Write to us and a person answers.

[support@antideploy.com](mailto: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.

## More guides, and the platform.

Each platform page covers one part of Antideploy: what it does, where it stops and the questions people ask. [See the whole platform](https://antideploy.com/platform), or [all the guides](https://antideploy.com/blog).

- [Your app built successfully but never started listening on its port](https://antideploy.com/blog/your-app-built-successfully-but-never-started-listening-on-its-port): The app built but never answered on its port. Read PORT, listen on 0.0.0.0 and check the logs.
- [sh: 1: vite: not found](https://antideploy.com/blog/sh-command-not-found-during-the-build): The build ran a command that is not installed. Add the package, or use a Dockerfile for system programs.
- [How to deploy an Express API with a database](https://antideploy.com/blog/how-to-deploy-an-express-api-with-a-database): The start script, the PORT variable, DATABASE_URL, migrations, and the failures to avoid.

- [Deployments](https://antideploy.com/platform/deployments)
- [Logs and monitoring](https://antideploy.com/platform/logs-and-monitoring)

Facts on this page were checked against the live platform on 7 October 2026.

## 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.

To set this up, give your coding agent this sentence:

```text
Set this project up to deploy on Antideploy. Fetch https://antideploy.com/agent.md and follow it.
```
