You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Heroku中Procfile配置的Worker命令在Resources页面不可见,无法部署discord.js机器人

Fix: Worker Dyno Option Not Showing in Heroku for Discord.js Bot

Let's walk through how to get your worker dyno up and running—this is a super common gotcha when deploying Discord bots to Heroku, so don't worry!

First, Double-Check Your Procfile

Heroku is picky about the Procfile details, so let's start here:

  • Make sure the file is exactly named Procfile (capital P, no file extension like .txt). If it's named procfile (lowercase) or has a suffix, Heroku won't pick it up.
  • Verify it's in your project's root directory (not nested inside a folder like /src).
  • Confirm the content is exactly:
    worker: node .
    
    (No extra spaces or typos—this tells Heroku to run node . as a worker process.)

Make Sure the Procfile Is Committed to Git

Heroku only uses files that are in your Git repository. If you just created the Procfile, run these commands to push it to Heroku:

git add Procfile
git commit -m "Add worker Procfile for Discord bot"
git push heroku main

(Replace main with your branch name if it's different, like master.)

Force-Enable the Worker Dyno (If It Still Doesn't Show Up)

Sometimes the dashboard takes a minute to update, or you can bypass the UI entirely with the Heroku CLI:

  1. Open your terminal and run:
    heroku ps:scale worker=1
    
    This directly tells Heroku to spin up 1 worker dyno running your node . command.
  2. To turn off the default Web Dyno (since your bot doesn't need a web server), run:
    heroku ps:scale web=0
    
    This will stop wasting resources on a web process you don't use.

Refresh and Re-Deploy If Needed

If the Resources page still isn't showing the worker option:

  • Refresh the Heroku Dashboard page—sometimes the UI lags behind the actual server state.
  • Go to the Deploy tab in your app's dashboard and click "Deploy Branch" to trigger a fresh deployment. This will make sure Heroku re-scans your Procfile.

Bonus: Specify Your Node Version

Discord.js (especially v14+) requires a specific Node.js version. Add this to your package.json to avoid compatibility issues:

"engines": {
  "node": "16.x" // Use 16.9.0 or higher for discord.js v14
}

After following these steps, your worker dyno should be running, and your Discord bot should go online!

内容的提问来源于stack exchange,提问作者BullDoze

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.27 12:52:45