Docs · Running your bot

Installing packages: requirements.txt and package.json

All docs

When your bot starts, packages are installed from requirements.txt (Python) or package.json (JavaScript) in the top folder. That only happens when the file has changed since the last start, or you switched version, so a normal restart skips it and is quick. The console says which it did.

Python: requirements.txt

One package per line, with the name as it is on PyPI:

discord.py==2.6.3
aiohttp
python-dotenv

If you do not know what your bot uses, run pip freeze > requirements.txt on the computer where it works. That lists everything installed there, which is more than you need if you did not use a virtual environment, so trim it to what your bot imports.

Packages are installed for your user into the .local folder.

JavaScript: package.json

Your dependencies go in package.json, the same file you have on your computer. Upload it with your code, or keep it in your repository. Upload the lock file too if you have one:

  • package-lock.json: installed with npm.
  • yarn.lock: installed with yarn.
  • pnpm-lock.yaml: installed with pnpm.

Development dependencies are installed as well, so a start script that builds TypeScript first still works. Install scripts of your dependencies run too, as they do on your computer, so native modules such as @discordjs/opus and better-sqlite3 build. (If your package.json has its own allowScripts list, or pnpm's onlyBuiltDependencies, that is respected instead.) Never upload node_modules: it was built for your computer and is created here.

Pin versions you depend on

A package without a version installs the newest release. Months later, a change that triggers a reinstall can pull in a new major version underneath you. Pin what matters: discord.py==2.6.3 in requirements.txt, or commit your lock file for JavaScript.

Updating a package

Change the version in the file and restart. The file changed, so packages are installed again.

Starting clean

Deleting a package from the file does not remove what is already installed. To start clean:

  1. Stop the bot.
  2. In Files, delete .local (Python) or node_modules (JavaScript).
  3. Start the bot. Everything is installed from scratch, which takes longer this once.

When an install fails

The console shows the error, adds a hint where it can, and starts your bot anyway. Common ones:

  • No matching distribution found for ... (pip) or ETARGET / No matching version (npm). The name is wrong, the version does not exist, or the package does not support your version of Python or Node. Check the name on pypi.org or npmjs.com, and try another version under Startup.
  • Could not build wheels for ... or gyp ERR!. The package needs compiling. A newer release of it often has a ready-made build, so try pinning a recent version. If that does not work, tell us which package.
  • discord and discord.py both listed. They conflict. Keep only discord.py. The same goes for forks such as py-cord and nextcord: pick one.
  • No space left on device. Your plan's disk is full. See what is large in Files (old logs and backups you uploaded are the usual suspects).

What is already there

Every server has git, ffmpeg (for bots that play audio) and a C compiler. The Node.js versions also have npm, yarn, pnpm and the build tools native packages such as better-sqlite3 need. You cannot install system packages with apt; if your bot needs one that is missing, ask us.

Something here wrong or out of date? Tell us and it gets fixed.