ESN Docs

Docs › Discord bots

How to host a TypeScript Discord bot 24/7

3 min readUpdated Nov 3, 2026

Build your TypeScript bot once, upload the JavaScript it makes, and it runs 24/7 on ESN.

Before you start #

You need an ESN account (create one) and a bot plan from $0.50/month on the plans page. Most small bots run fine on Nano (256 MB) or Starter (512 MB); see how much RAM a bot needs.

  • A TypeScript bot (usually discord.js) that builds on your computer with npx tsc.
  • A tsconfig.json with an output folder, for example "outDir": "dist".
  • Your bot token from the Discord Developer Portal (how to get it).

How it works #

The Node.js server runs plain JavaScript. So you build your TypeScript into JavaScript on your computer, upload the built files, and point the server at the built start file. Your .ts source can stay on your computer or in Git.

Build your bot #

  1. Make sure tsconfig.json has "outDir": "dist" and a "target" Node.js 22 understands, such as "ES2022".
  2. Run npx tsc. You should get dist/index.js (or whatever your entry file is called).
  3. Test it locally once: node dist/index.js. If it logs in here, it will log in on ESN.
  4. Check package.json: discord.js and dotenv must be under dependencies. typescript and @types/* can stay in devDependencies.

If your project uses ES modules ("type": "module" in package.json, or "module": "NodeNext"), keep that setting. Node.js runs the built .js files the same way it did on your computer.

Upload and start on ESN #

  1. Open your server. It should be set up as Discord bot (Node.js).
  2. In Files, upload package.json, package-lock.json (if you have one), .env and the whole dist folder. Zip them and use Unarchive if that's easier. Skip node_modules.
  3. In Startup, set Main JavaScript File to dist/index.js.
  4. Go to Console and press Start. The server runs npm install and then node dist/index.js.
  5. Each time you change the code: run npx tsc again, upload the new dist folder, and press Restart.

Common TypeScript bot errors #

  • Cannot find module '/home/container/dist/index.js': the dist folder isn't in the top folder, or the Main JavaScript File path is wrong.
  • SyntaxError: Cannot use import statement outside a module: your build output uses import but package.json has no "type": "module". Add it, or build to CommonJS ("module": "CommonJS").
  • Cannot find module 'discord.js': it's listed under devDependencies. Move it to dependencies.
  • Token and intent errors are the same as in plain discord.js: see common discord.js errors.

FAQ #

Can the server run my .ts files directly?

The Node.js server runs node on a JavaScript file. The tested way is to build with npx tsc on your computer and upload the dist folder.

Do I upload node_modules?

No. The server runs npm install from your package.json on every start.

Will my TypeScript bot stay online when my PC is off?

Yes. It runs on ESN's servers, not your computer.

How much does it cost?

ESN bot hosting starts from $0.50/month. All plans are on panel.esnoffical.com/plans.

Host it on ESN. Discord bot hosting from $0.50/month, with a full control panel. See plans · or ask in the ESN Systems Discord.

Still stuck? Use the live chat on the panel or ask in the ESN Systems Discord. Last updated November 3, 2026.