Skip to main content

Dependency Management

Replit supports a variety of languages and dependency management systems through the Dependencies tool. This section will cover the different types of dependencies and how to manage them in your Repl.

Imported Packages

Packages imported directly from your code are managed in the Imports tab. This tab allows you to view and manage the packages grouped by language. Links are also provided to the appropriate packager file, such as package.json for Node.js.

Imports tab for a project using Node.js and Python

Search and add packages

Clicking on Add new package will allow you to search for and install new packages. The language dropdown provides quick access between packagers.

Node.js package search for 'React'

You can view installation progress and relevant errors in the Console tab.

Example console output for an uninstalled package

The Universal Package Manager

Replit will install most packages using the universal package manager. To see which languages and package managers are supported, please check out UPM: Supported Languages.

If you prefer using the CLI, you can still use language-specific package managers such as poetry or npm. Any changes to the packager files will be reflected in the Dependencies tool, but require the respective CLI command or using the Run button to properly update.

Import guessing

As your code evolves, we analyze your project for missing dependencies and automatically guess what needs to be installed to get your code to run. For example, if you add import flask to main.py, the next time you select Run, you'll see a section in the Console indicating that the latest version of Flask is being installed:

upm output showing packages being installed

Guessing failures

This section helps you with the command to run a particular version of your package. If there's a particular version that you need, or we guessed the wrong package entirely, you can run upm in the shell to resolve the conflict:

upm add 'flask==2.3.3' 

To install additional packages in your Workspace, open a new tab by selecting the + sign and searching for Packages. Select the packages of your choice and select Install. Additional options for package guessing can be configured in the .replit file.

Python package managers

When you create a Python Repl, your package manager will be poetry by default. This means that you will not be able to use pip install to manage dependencies manually. Instead of running pip install <package>, you can instead run poetry add <package> or upm add <package>, which will do the same thing.

pip is one of the earliest, and consequently most popular, package managers for Python. You can use pip as your Repl's package manager instead of poetry. Follow the steps below:

  1. In the Tools pane, select the Shell tab to add the common requirements.txt file using the following command:
touch requirements.txt
  1. Delete the poetry.lock file.

  2. Move your dependencies from [tool.poetry.dependencies] to requirements.txt. Note that the flask = "^3.0.2" in pyproject.toml's [tool.poetry.dependencies] section would become flask>=3.0.2,<4 in requirements.txt.

  3. Finally, delete the other [tool.poetry...] sections from pyproject.toml.

After the above changes, the packaging infrastructure will use pip for all future operations.

Now, as you add code to your main.py file, any time you select Run, upm will determine whether there are any missing packages for your imports, find the latest versions of packages that provide those imports, and install them automatically.

Advanced Configuration

Replit supports all programming languages through integration with Nix. Nix is a tool for managing software packages and system configurations. The System (Advanced) tab provides quick access to Nix support for your Repl.

System (Advanced) tab for a project using Node.js and Python

System Modules

Modules combine support for programming languages, formatters, and packagers. These provide the foundation for your Repl. If you create a Repl from a template or GitHub repository, we will automatically install the modules that are required for the languages used.

If you want to start with a blank Repl, you will need to install a module under System Modules before you can use the Imports tab. You can also add more modules to support additional languages.

You can further customize modules and other Nix settings using the .replit file.

System Dependencies

If you need more specific support for a language or other system-level dependencies, you can add Nix packages under System Dependencies. These can also be managed in your replit.nix file.

Was this helpful?