Deploy Discord Bot | discord.js v14 Starter with a Lockfile That Installs
discord.js v14 starter with slash commands and a matching lockfile.
discordjs-railway-starter
Just deployed
Deploy and Host a discord.js Bot on Railway
A minimal slash-command bot built on discord.js v14 — a working starting point you extend, not a demo you have to repair first.
About Hosting a discord.js Bot
A Discord bot is a long-running Node process holding a websocket to Discord's gateway. There is no HTTP endpoint and no public URL, so hosting means keeping a worker alive, restarting it when it dies, and passing the token through the environment. The part that quietly breaks is earlier than any of that: the install step. A committed lockfile that has drifted from package.json will stop a deployment before a single line of bot code runs.
Common Use Cases
- A moderation or utility bot for your own server
- A notification bot posting build results, alerts or scheduled digests into a channel
- A base for a larger bot with many slash commands
Dependencies for discord.js Bot Hosting
discord.jsv14 — the only direct dependency;RESTandRoutescome from it directly, so the separate@discordjs/restanddiscord-api-typespackages are not needed- A committed
package-lock.jsongenerated from exactly that dependency set
Deployment Dependencies
Implementation Details
The long-standing discord.js starter on Railway ships a yarn.lock that no longer matches its package.json. Railway's builder installs with --frozen-lockfile, which refuses to reconcile the difference and exits non-zero:
warning discord.js@13.17.1: Version 13 is no longer supported.
error Your lockfile needs to be updated, but yarn was run with `--frozen-lockfile`.
Build Failed: process "yarn install --frozen-lockfile" did not complete successfully: exit code: 1
The deployment dies during install. Nothing about the bot code is involved.
This template commits a package-lock.json generated from its own package.json, so npm ci installs the identical tree on every build — deterministic and, more to the point, successful.
The code is also on discord.js v14 rather than the v13 line upstream marks as no longer supported: GatewayIntentBits instead of Intents.FLAGS, Events constants, isChatInputCommand(), and API v10 for command registration.
Two operational details worth keeping when you extend it: commands are loaded relative to __dirname rather than the working directory, and a missing or rejected DISCORD_TOKEN exits with a message naming the variable instead of an unhandled rejection.
Getting Started
- Create an application in the Discord Developer Portal.
- Under Bot, reset the token and set it as
DISCORD_TOKEN. - Under OAuth2 → URL Generator, select scopes
botandapplications.commands, then open the generated URL to invite the bot.
Slash commands register globally on startup; Discord can take a few minutes to show them. Add your own by dropping a file exporting data and execute into src/commands/.
Why Deploy a discord.js Bot on Railway?
Railway is a singular platform to deploy your infrastructure stack. Railway will host your infrastructure so you don't have to deal with configuration, while allowing you to vertically and horizontally scale it.
By deploying a discord.js bot on Railway, you are one step closer to supporting a complete full-stack application with minimal burden. Host your servers, databases, AI agents, and more on Railway.
Template Content
discordjs-railway-starter
ak40u/discordjs-railway-starterDISCORD_TOKEN
