NODE.JS · DISCORD.JS

Deploy a Node.js Discord bot

Prepare a discord.js project for Botkeep with a predictable start script, declared dependencies and a token read from the runtime environment.

6 min readUpdated 28 Aug 2026Beta documentation
Product preview

The interface is functional with local demo data. Live hosting, provisioning and production security controls are not connected yet.

Before you start
  • A working Discord application and bot user
  • A Node.js project using discord.js
  • A package.json committed or included in the ZIP
  • No live token stored in source control

1. Give the project a clear entry point

Botkeep needs one process and one deterministic start command. Put the entry file in a predictable location and declare the command in package.json. The exact Node.js versions available at launch will be shown in the runtime selector.

package.jsonexample
{
  "name": "moderation-bot",
  "private": true,
  "scripts": {
    "start": "node src/index.js"
  },
  "dependencies": {
    "discord.js": "^14.0.0"
  }
}

2. Read the Discord token from the environment

Never commit a bot token to GitHub or include it in a ZIP. Read DISCORD_TOKEN at runtime and fail clearly when it is missing.

src/index.jsexample
import { Client, GatewayIntentBits } from 'discord.js'

const token = process.env.DISCORD_TOKEN
if (!token) throw new Error('DISCORD_TOKEN is required')

const client = new Client({
  intents: [GatewayIntentBits.Guilds],
})

client.once('ready', () => {
  console.log(`Connected as ${client.user.tag}`)
})

await client.login(token)

3. Keep installs repeatable

Commit package-lock.json when you use npm so the build can install the same dependency graph. Do not upload node_modules; dependencies belong in package.json and the lockfile. Remember that package install scripts execute code during a build, so use packages you trust.

  • Commit package.json and package-lock.json.
  • Keep the start command non-interactive.
  • Write logs to stdout and stderr.
  • Use the persistent volume only for data that must survive a restart.

4. Confirm the Botkeep settings

Choose Node.js, select GitHub or ZIP, confirm npm start as the command and add DISCORD_TOKEN as a secret. Review the resource allocation before creating the bot.