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.
- Difficulty:
- Beginner
- Time:
- 10 minutes
On this page
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
In the billing panel, open Services, click your bot service and choose Auto Login to Panel.
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 |
Install Branch | The branch to use, for example |
User Uploaded Files |
|
Auto Update |
|
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 |
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
Make sure
package.jsonlists every package your bot uses underdependencies.Don't upload
node_modules. It is large, andnpm installcreates a fresh copy on the server.In Files, upload your project so that
package.jsonand your main file sit in the top folder, not in an extra sub-folder. For many files, upload a.zipand unarchive it, or use SFTP. See Using the file manager and How to connect with SFTP.In Startup, set User Uploaded Files to
1and Main file to your start file (exact name, including capital letters and any folder, such assrc/index.js).
Option B: Deploy from GitHub
In Startup, set User Uploaded Files to
0, paste your repo link into Git Repo Address and enter the Install Branch.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.
Set Auto Update to
1if you want every restart to pull your newest commits.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.
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.
Start the bot
Click Start and open Console. The first
npm installcan take a minute.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 |
|---|---|
| Add the package to |
| 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.
Frequently asked questions
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.
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.
Was this article helpful?
Related articles
No domain? Open your website, API or bot dashboard over HTTPS with a free SSL certificate from Endercloud. Port first, a dash, then your node name, always on ender.co.in, like https://25808-agni.ender.co.in.
Open Discord Link in the billing panel's user menu and connect your Discord account to get notifications on Discord and the client role in the Endercloud Discord server.
Install DiscordSRV, create a Discord bot with the Server Members and Message Content intents, then put the bot token and channel ID in DiscordSRV's config.yml and restart.
Switch your bot from one language to another with Settings → Change Egg, and change the Node.js, Python or Java version with the Docker Image list in Startup.
