ACLClouds
ACLClouds

How do I install my bot’s dependencies?

List your bot’s dependencies in package.json or requirements.txt: ACLClouds installs them when the bot starts. If installation fails, read the console.

Dependencies must be described in the project. Do not import node_modules or a virtual environment created on your computer.

Step-by-step procedure

  1. Declare Node.js dependencies

    Put package.json and its lockfile at the root of the bot files: the platform installs the dependencies at start, with no command to run.

  2. Declare Python dependencies

    Put requirements.txt, or pyproject.toml if you have none, at the root: the platform installs the packages at start, with no virtual environment to create.

  3. Read the first useful error

    If installation fails, the console shows the installer output: fix the Node.js or Python version, the package name or the lockfile.

  4. Restart and verify the bot

    Restart the bot to run the installation again, then check in the console that the dependencies are installed and the bot loads.

Create package-lock.json on your computer

npm install discord.js dotenv

Pinning Python dependencies locally

python -m venv .venv
source .venv/bin/activate
pip install discord.py python-dotenv
pip freeze > requirements.txt

Automatic installation at startup

There is no terminal to open. At each start, the platform compares the dependency files and the Node.js or Python version with the last successful installation. If nothing has changed, the bot starts right away. Otherwise the console shows “Installing dependencies (npm install)”, or pip install for Python, then the installer output and “Dependencies installed in 12 s”.

For Node.js, the lockfile you provide is followed: package-lock.json, yarn.lock or pnpm-lock.yaml. Without a lockfile, versions are picked from package.json at install time and may differ from the ones you tested on your computer. Package install scripts, such as building a native module, run in an isolated environment.

For Python, the platform installs requirements.txt, or failing that the dependencies of the [project] section of pyproject.toml. Packages go into the bot’s .deps folder, which Python already knows about: do not upload venv or .venv.

When the installation fails

The console shows “Dependency installation failed” followed by the cause. Scroll up to the installer’s first error line: the next ones are often just its consequence. Fix the file concerned, then restart the bot to run the installation again.

If the code imports a missing package, the console shows a “Missing module” card with an “Install” button. It adds the package to package.json or requirements.txt, then restarts the bot to install it. Afterwards, replace the added version with the one you tested.

Checking the installation

After a dependency change, the console should show “Dependencies installed in 12 s”, then the command that was run, for example $ node index.js or $ python -u bot.py, and finally your code’s messages. At the next restart, with no file changes, no installation should appear.

Frequently asked questions

Should I upload the node_modules folder?

No. Before each installation, the platform deletes the dependency folder (node_modules or .deps) and rebuilds it for its own system. Uploading it only slows down the transfer and takes up space: on the free plan, an upload is limited to 100 MB. Leave it out of your archives and of Git.

Why ModuleNotFoundError: No module named 'dotenv' when I added dotenv?

The imported name often differs from the name to install: import dotenv needs the python-dotenv package, import yaml needs PyYAML and import PIL needs Pillow. Write the package name in requirements.txt, not the module name, then restart the bot.

What does the “Reinstall dependencies” button do?

In the “Startup” tab, this button runs the dependency installation again from the current files, then restarts the bot. Your files and variables are not changed. Use it if the installation looks incomplete although package.json and requirements.txt have not changed.