Skip to main content
RapidDev - Software Development Agency
replit-tutorial

How to manage dependencies in Replit

Manage dependencies in a large Replit project using three layers: language-level package managers (npm for Node.js, pip for Python), system-level Nix packages for native binaries, and the GUI package manager in the Tools dock. Use replit.nix for system dependencies like image libraries or database clients, package.json or requirements.txt for application dependencies, and the onBoot command to ensure everything installs automatically on startup.

What you'll learn

  • Install and manage npm/pip packages via Shell and the GUI package manager
  • Configure replit.nix for system-level dependencies like image libraries and database clients
  • Use the .replit hidden array and onBoot command to keep your environment clean and reproducible
  • Monitor storage usage and manage dependency sizes on different plan tiers
Book a free consultation
4.9Clutch rating
600+Happy partners
17+Countries served
190+Team members
Beginner7 min read15-20 minutesAll Replit plans. Starter: ~2 GiB storage. Core: 50 GiB storage. Pro: 50+ GiB storage.March 2026RapidDev Engineering Team
TL;DR

Manage dependencies in a large Replit project using three layers: language-level package managers (npm for Node.js, pip for Python), system-level Nix packages for native binaries, and the GUI package manager in the Tools dock. Use replit.nix for system dependencies like image libraries or database clients, package.json or requirements.txt for application dependencies, and the onBoot command to ensure everything installs automatically on startup.

Manage Dependencies in Large Replit Projects with npm, pip, and Nix

Large projects often need more than just npm packages — they need system-level libraries, database clients, image processors, or other native binaries that package managers alone cannot provide. Replit uses a layered dependency system: language package managers (npm, pip, poetry) for application code, Nix for system-level packages, and a GUI tool for quick installs. This tutorial explains how all three layers work together and how to configure them for a large, stable project.

Prerequisites

  • A Replit account on any plan (Core or Pro recommended for large projects)
  • A Replit App with existing code
  • Basic familiarity with the Shell tab and package managers
  • No prior experience with Nix required

Step-by-step guide

1

Install application dependencies with npm or pip

Open the Shell tab and use your language's package manager to install dependencies. For Node.js projects, use npm install. For Python, use pip install. These install packages into your project directory (node_modules for npm, a virtual environment for pip). Always use --save or --save-dev flags with npm so dependencies are recorded in package.json. For pip, generate a requirements.txt file after installing packages so the list is reproducible.

typescript
1# Node.js install and save to package.json
2npm install express cors dotenv
3npm install --save-dev jest typescript
4
5# Python install and freeze to requirements.txt
6pip install flask requests sqlalchemy
7pip freeze > requirements.txt

Expected result: Packages are installed and recorded in package.json or requirements.txt. Running 'npm ls' or 'pip list' in Shell shows the installed packages.

2

Use the GUI package manager for quick installs

Replit provides a graphical package manager accessible from the Tools dock. Click the Dependencies tool (or search for 'Packages' in the search bar) to open it. Type a package name to search, then click the install button. The GUI handles the installation command for you and adds the package to your dependency file automatically. This is useful for beginners or when you want to browse available packages without memorizing exact names.

Expected result: Packages install through the GUI and appear in your package.json or requirements.txt the same way as Shell-installed packages.

3

Configure replit.nix for system-level dependencies

Some packages need system libraries that npm or pip cannot provide — for example, image processing libraries need libvips, database clients need PostgreSQL headers, and PDF generation needs poppler. Replit uses Nix to manage these system-level dependencies. Open .replit (enable 'Show hidden files'), then open replit.nix. Add the required system packages to the deps array. Search for available packages at search.nixos.org/packages. After editing replit.nix, type 'exit' in Shell to restart the environment and load the new packages.

typescript
1# replit.nix system-level dependencies
2{ pkgs }: {
3 deps = [
4 pkgs.nodejs-20_x
5 pkgs.nodePackages.typescript-language-server
6 pkgs.python311
7 pkgs.postgresql
8 pkgs.libvips
9 pkgs.ffmpeg
10 pkgs.imagemagick
11 ];
12}

Expected result: After running 'exit' in Shell, the system packages are available. You can verify by running the package command (e.g., 'ffmpeg --version' or 'psql --version') in Shell.

4

Add quick Nix packages via the .replit file

For simpler system dependencies, you can skip editing replit.nix and add packages directly in the .replit file under the [nix] section. This is a quicker method for small additions. The packages listed here are installed alongside those in replit.nix. Make sure the Nix channel is set to a recent stable version to ensure package compatibility.

typescript
1# .replit file quick Nix packages
2[nix]
3channel = "stable-24_05"
4packages = ["cowsay", "htop", "curl", "jq"]

Expected result: The listed packages are available in Shell after the environment restarts. Running 'htop' or 'jq --version' confirms availability.

5

Set up onBoot for automatic dependency installation

To ensure dependencies install automatically whenever the Repl starts (especially after a restart or when a collaborator opens the project), add an onBoot command to your .replit file. This runs once at startup and handles the initial setup. For projects that use both npm and pip, chain the commands with &&.

typescript
1# .replit file
2onBoot = "npm install && pip install -r requirements.txt"

Expected result: Opening the Repl automatically installs all application dependencies. Collaborators do not need to manually run npm install or pip install.

6

Monitor storage usage and manage dependency sizes

Large projects with many dependencies can hit storage limits, especially on the Starter plan (approximately 2 GiB). Check your current storage usage by clicking the Resources panel (stacked computers icon in the left sidebar). It shows RAM, CPU, and storage breakdown. To reduce dependency size, remove unused packages with npm prune or pip uninstall, avoid installing heavy packages globally, and use .replit hidden to hide large directories like node_modules from the file tree without deleting them.

typescript
1# Check disk usage from Shell
2du -sh node_modules/
3du -sh .local/
4
5# Remove unused npm packages
6npm prune
7
8# Remove a specific unused package
9npm uninstall unused-package-name

Expected result: You can see your current storage usage in the Resources panel and identify which directories consume the most space.

Complete working example

.replit
1# .replit dependency management for a large project
2
3entrypoint = "src/index.js"
4modules = ["nodejs-20:v8-20230920-bd784b9"]
5
6# Install dependencies automatically on startup
7onBoot = "npm install"
8
9# Run the application
10run = "node src/index.js"
11
12# Quick system packages
13[nix]
14channel = "stable-24_05"
15packages = ["curl", "jq"]
16
17# Environment variables for development
18[run.env]
19NODE_ENV = "development"
20
21# Deployment configuration
22[deployment]
23build = ["sh", "-c", "npm ci && npm run build"]
24run = ["sh", "-c", "NODE_ENV=production node dist/index.js"]
25deploymentTarget = "cloudrun"
26
27# Port configuration
28[[ports]]
29localPort = 3000
30externalPort = 80
31
32# Hide large/generated directories from file tree
33hidden = [
34 ".config",
35 "package-lock.json",
36 "node_modules",
37 ".local",
38 "dist",
39 ".cache"
40]

Common mistakes when managing dependencies in Replit

Why it's a problem: Not running 'exit' in Shell after editing replit.nix, so new system packages are not loaded

How to avoid: After any change to replit.nix, type 'exit' in Shell. This restarts the Nix environment and loads the new packages.

Why it's a problem: Using the wrong package name format in replit.nix (e.g., 'nodejs' instead of 'pkgs.nodejs-20_x')

How to avoid: Search for the exact package name at search.nixos.org/packages. Always use the pkgs. prefix in replit.nix.

Why it's a problem: Running out of storage on the Starter plan due to large node_modules

How to avoid: Run 'npm prune' to remove unused packages. Check 'du -sh node_modules/' to see the size. Consider upgrading to Core (50 GiB) for large projects.

Why it's a problem: Installing packages globally instead of as project dependencies

How to avoid: Use 'npm install package-name' (not npm install -g) so packages are project-scoped and available to all collaborators and deployments.

Best practices

  • Always record dependencies in package.json (npm) or requirements.txt (pip) so the project is reproducible
  • Use replit.nix for system-level libraries and npm/pip for application-level packages — do not mix their responsibilities
  • Set onBoot in .replit to automatically install dependencies when the Repl starts
  • Run 'exit' in Shell after editing replit.nix to reload the Nix environment
  • Use the Resources panel to monitor storage and identify oversized dependency directories
  • Hide node_modules, .local, and .cache in the .replit hidden array to keep the file tree navigable
  • Use npm ci instead of npm install in deployment builds for deterministic, faster installations
  • Search for Nix packages at search.nixos.org/packages to find exact package names before adding them to replit.nix

Still stuck?

Copy one of these prompts to get a personalized, step-by-step explanation.

ChatGPT Prompt

I have a large Node.js project in Replit that needs system-level dependencies like PostgreSQL and image processing. How do I configure replit.nix and package.json to manage both system and application dependencies?

Replit Prompt

Configure dependency management for this project. Add PostgreSQL, libvips, and ffmpeg to replit.nix. Set up onBoot in .replit to run npm install automatically. Add node_modules and .cache to the hidden array. Show me how to check storage usage.

Frequently asked questions

npm packages are JavaScript/Node.js libraries for your application code (Express, React, etc.). Nix packages are system-level binaries and libraries (PostgreSQL, FFmpeg, ImageMagick) that run on the operating system. You need both for projects that depend on native system tools.

Starter plan provides approximately 2 GiB. Core plan provides 50 GiB. Pro plan provides 50+ GiB. Nix packages from Replit's prebuilt cache do not count against your quota.

npm packages in node_modules persist across restarts. However, setting onBoot = "npm install" in .replit ensures any missing packages are restored automatically. Nix packages are always available after replit.nix is configured.

Yes. Agent v4 automatically installs dependencies when building applications. It configures package.json, replit.nix, and installs packages as needed. You can also prompt Agent directly: 'Install PostgreSQL client and image processing libraries for this project.'

The deployment build step runs in a clean environment. Include npm ci or npm install in the [deployment] build command. Nix packages from replit.nix are available in deployments automatically.

Replit supports polyglot projects. Add both Node.js and Python modules to your .replit file. Use npm install for JavaScript packages and pip install for Python packages. Set onBoot to install both: 'npm install && pip install -r requirements.txt'.

Common causes: wrong package name (check search.nixos.org), outdated Nix channel (update to stable-24_05 or later), or unfree packages not enabled. Check the exact error by running 'cat /run/replit/env/error' in Shell.

For projects with complex dependency trees, native module conflicts, or multi-language requirements, the RapidDev team can help set up a clean, scalable dependency management strategy that prevents version conflicts and keeps builds fast.

RapidDev

Talk to an Expert

Our team has built 600+ apps. Get personalized help with your project.

Book a free consultation

Need help with your project?

Our experts have built 600+ apps and can accelerate your development. Book a free consultation — no strings attached.

Book a free consultation

We put the rapid in RapidDev

Need a dedicated strategic tech and growth partner? Discover what RapidDev can do for your business! Book a call with our team to schedule a free, no-obligation consultation. We'll discuss your project and provide a custom quote at no cost.