Heroku中Procfile配置的Worker命令在Resources页面不可见,无法部署discord.js机器人
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 namedprocfile(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:
(No extra spaces or typos—this tells Heroku to runworker: node .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:
- Open your terminal and run:
This directly tells Heroku to spin up 1 worker dyno running yourheroku ps:scale worker=1node .command. - To turn off the default Web Dyno (since your bot doesn't need a web server), run:
This will stop wasting resources on a web process you don't use.heroku ps:scale web=0
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

