How to Host a Node.js (discord.js) Bot

This guide walks you through uploading a Node.js bot built with discord.js to your GuavaHost panel, installing its dependencies from package.json, and starting it with the right command so it runs 24/7.

This guide walks you through uploading a Node.js bot built with discord.js to your GuavaHost panel, installing its dependencies from package.json, and starting it with the right command so it runs 24/7.

Before you start

You need three things ready on your computer:

  • Your bot's code, with a main file such as index.js.
  • A package.json file that lists discord.js (and any other libraries) under dependencies.
  • Your bot token from the Discord Developer Portal.

If you do not have a package.json yet, run npm init -y in your project folder, then npm install discord.js. That creates the file and records the dependency. You do not need to upload the nodemodules` folder; the panel rebuilds it for you.

Step 1: Upload your bot

  • Open your server from guavahost.com/account.
  • Go to the Files tab.
  • Upload your project files, including index.js and package.json. You can drag them straight into the file browser, or use SFTP with the details on the Settings tab (SFTP is a secure way to move files between your computer and your server, and FileZilla is a good free client).
  • Leave nodemodules` behind; skipping it keeps the upload small and fast.

Step 2: Point the panel at your main file

Open the Startup tab. You will see your server variables. Set the main file variable (often called the bootstrap or JS file) to your entry file, for example index.js. This is the file the panel runs with node.

Step 3: Add your token safely

Still on the Startup tab, paste your token into the token variable. Never hard-code it inside index.js. In your code, read it from the environment instead:

client.login(process.env.DISCORDTOKEN);`

Now your token lives in the panel, not in a file you might share or commit.

Step 4: Start the bot

Press Start. When the server starts, the panel sees your package.json and automatically runs npm install to download discord.js and everything else you listed, then launches your bot with node index.js. The first start takes a little longer while packages download.

Watch the Console. A healthy start ends with your own ready message, something like Logged in as YourBot#1234. If you see it, switch to Discord and your bot should show as online.

If something goes wrong

  • Cannot find module 'discord.js': the library is not in your package.json dependencies. Add it, re-upload the file, and restart so npm install runs again.
  • Used disallowed intents: enable the Gateway Intents your bot needs in the Discord Developer Portal, under your application's Bot settings, then restart.
  • An invalid token was provided: check the token variable on the Startup tab for stray spaces, or regenerate the token in the Developer Portal and paste the new one.
  • SyntaxError or a crash on start: read the stack trace in the Console; it names the file and line so you can fix it.

Updating your bot later

When you change your code, re-upload the changed files on the Files tab and press Restart. If you added a new library to package.json, the restart triggers a fresh npm install automatically. Take a snapshot on the Backups tab first if the change is risky, so you can restore in one click.

Still stuck? Jump into our Discord at discord.gg/GuavaHost and the team will help you out.