---
title: "How to host a Node.js Discord bot"
url: https://help.endercloud.in/docs/host-a-nodejs-discord-bot
category: "Bot Hosting"
type: Guide
tags: ["bots", "discord", "nodejs"]
keywords: "discord.js hosting, host discord bot 24/7, node bot hosting, index.js, package.json, npm install, cannot find module, main file, git repo address, github private repo, personal access token, auto update, ts-node, typescript bot, node version, host discord bot, how to host discord bot, discord.js bot hosting, upload bot files, deploy bot from github, node_modules, error cannot find module, bot not starting, typescript discord bot, discord bot hosting india, dicord bot"
difficulty: beginner
time: "10 minutes"
updated: 2026-11-14
source: Endercloud Knowledge Base (official)
---

# How to host a Node.js Discord bot

> Upload your bot (without node_modules) or link a GitHub repo in Startup, set the Main file, then click Start. npm install runs automatically when package.json exists.

To run a Node.js bot (for example one made with discord.js) on Endercloud, put your code on the server, either by uploading it or by linking a GitHub repository, set the **Main file** in **Startup**, and click **Start**. If your project has a `package.json`, the server runs `npm install` for you on every start.

## Open your bot in the Game Panel

1.  In the [billing panel](https://billing.endercloud.in), open **Services**, click your bot service and choose **Auto Login to Panel**.
    
2.  On the Game Panel home page, click **Manage server** on your bot. Right after purchase its status may show **Installing** for a short while.
    

The bot menu has **Dashboard, Console, Settings, Activity**, then **Files, Databases, Backups, Network**, then **Schedules, Users, Startup**. USA bots run in Virginia, with an address like `astra.endercloud.in:<port>`; a Discord bot only needs it if it also runs a web page or webhook.

## The Startup variables

Open **Startup**. These are the settings of the Node.js bot server:

| Variable | What it does |
| --- | --- |
| **Git Repo Address** | The GitHub (or other Git) link to your code, for example `https://github.com/you/my-bot.git`. Leave empty if you upload files. |
| **Install Branch** | The branch to use, for example `main`. |
| **User Uploaded Files** | `1` if you upload the code yourself, `0` to use the Git repo. |
| **Auto Update** | `1` pulls the latest code from the repo every time the bot starts. |
| **Additional Node packages** | Extra packages to install on start, separated by spaces. |
| **Git Username** / **Git Access Token** | Needed only for private repos (see below). |
| **Uninstall Node packages** | Packages to remove on start, separated by spaces. |
| **Main file** | The file that starts your bot. Default `index.js`. Can be a `.js` or `.ts` file (TypeScript runs with ts-node). |
| **Additional Arguments** | Extra arguments added to the start command. Leave empty unless your bot needs them. |

The **Docker Image** list on the same page picks the Node.js version, from Nodejs 12 to Nodejs 25. Choose one your library supports. Current discord.js v14 needs a recent Node.js, so pick a current LTS version rather than an old one.

Every time you press **Start**, the server does this in order: pulls from Git (if **Auto Update** is `1`), installs or removes the extra packages you listed, runs `npm install` if `package.json` exists, then runs your **Main file**.

## Option A: Upload your files

1.  Make sure `package.json` lists every package your bot uses under `dependencies`.
    
2.  **Don't upload `node_modules`.** It is large, and `npm install` creates a fresh copy on the server.
    
3.  In **Files**, upload your project so that `package.json` and your main file sit in the top folder, not in an extra sub-folder. For many files, upload a `.zip` and unarchive it, or use SFTP. See [Using the file manager](/docs/using-the-file-manager) and [How to connect with SFTP](/docs/how-to-connect-to-your-server-with-sftp).
    
4.  In **Startup**, set **User Uploaded Files** to `1` and **Main file** to your start file (exact name, including capital letters and any folder, such as `src/index.js`).
    

## Option B: Deploy from GitHub

1.  In **Startup**, set **User Uploaded Files** to `0`, paste your repo link into **Git Repo Address** and enter the **Install Branch**.
    
2.  For a **private repo**, enter your GitHub name in **Git Username** and a GitHub **personal access token** in **Git Access Token**. Your GitHub password will not work. A fine-grained token limited to that one repository with read-only **Contents** access is enough.
    
3.  Set **Auto Update** to `1` if you want every restart to pull your newest commits.
    
4.  The code is downloaded when the server is installed. If you added the Git settings after the bot was created, make a backup, then use **Settings → Reinstall Server** so the install runs again. The installer may not clone into a folder that already has files, so clear out old uploads first. If the code still doesn't appear, open a ticket.
    

> **Important:**
> **Keep tokens secret.** Never commit your Discord bot token or `.env` file to GitHub; add `.env` to `.gitignore` and upload it with **Files** instead. Treat your Git Access Token like a password: only give **Startup** access to sub-users you trust, and revoke the token on GitHub if it leaks. See [Keep your bot token safe](/docs/keep-your-bot-token-safe-with-environment-variables).

## Start the bot

1.  Click **Start** and open **Console**. The first `npm install` can take a minute.
    
2.  When you see your bot's "ready" or "logged in" message, check that it is online in Discord.
    

## Common console errors

| Error | What to do |
| --- | --- |
| `Cannot find module 'something'` | Add the package to `dependencies` in `package.json` (or to **Additional Node packages**) and restart. |
| `Cannot find module '/home/container/index.js'` | **Main file** doesn't match your file, or your files are in a sub-folder. |
| Git errors such as *Authentication failed* | Check **Git Username** and **Git Access Token**; the token may have expired or lack access to the repo. |
| An invalid token was provided | Your Discord token is wrong or was reset. Copy a fresh one from the Developer Portal. |
| Used disallowed intents | Enable the intent in the Developer Portal under **Bot → Privileged Gateway Intents**. |

If the bot starts but goes offline later, see [My bot keeps going offline](/docs/bot-keeps-going-offline).

## Frequently asked questions

**Q: Can I run TypeScript?**

Yes. Set **Main file** to your `.ts` file, for example `src/index.ts`, and it runs with ts-node. You can also compile to JavaScript yourself and point **Main file** at the output, such as `dist/index.js`.

**Q: How do I update my bot's code?**

With Git and **Auto Update** set to `1`, push to your branch and restart the bot. With uploaded files, stop the bot, overwrite the changed files, then start it.
