Manage packages in Replit using npm (Node.js), pip (Python), or the GUI package manager in the Tools dock. Install packages via Shell with npm install or pip install, keep dependencies tracked in package.json or requirements.txt, use lock files for reproducible builds, and configure onBoot in .replit to auto-install on startup. For deployment, use npm ci in the build step for deterministic production installs.
Install and Manage Packages with npm, pip, and Other Package Managers in Replit
Every non-trivial project needs external packages — React for UI, Express for servers, Flask for Python APIs. This tutorial covers the fundamentals of installing, updating, and managing packages in Replit using npm, pip, and the built-in GUI package manager. You will learn how to track dependencies properly, use lock files for reproducibility, and ensure packages are available in both development and deployed environments.
Prerequisites
- A Replit account on any plan
- A Replit App (Node.js or Python project)
- Basic familiarity with the Replit workspace and Shell tab
- No prior package management experience required
Step-by-step guide
Install npm packages via Shell
Install npm packages via Shell
Open the Shell tab from the Tools dock on the left sidebar. For Node.js projects, use npm install followed by the package name. The --save flag (default in modern npm) records the package in your package.json under dependencies. Use --save-dev for packages needed only during development (testing frameworks, build tools). npm creates a node_modules directory and a package-lock.json file that locks exact package versions.
1# Install a production dependency2npm install express34# Install multiple packages at once5npm install cors dotenv mongoose67# Install a development dependency8npm install --save-dev jest nodemon910# Install a specific version11npm install react@18.2.0Expected result: Packages install successfully and appear in package.json under dependencies or devDependencies. A package-lock.json file is created or updated.
Install Python packages with pip
Install Python packages with pip
For Python projects, use pip install in the Shell. After installing all needed packages, run pip freeze to generate a requirements.txt file that lists exact versions. This file serves the same purpose as package-lock.json — it ensures every collaborator and deployment uses identical package versions. Always commit requirements.txt to your project.
1# Install a single package2pip install flask34# Install multiple packages5pip install requests sqlalchemy flask-cors67# Install a specific version8pip install numpy==1.24.0910# Save all installed packages to requirements.txt11pip freeze > requirements.txt1213# Install from requirements.txt (for collaborators)14pip install -r requirements.txtExpected result: Python packages install successfully. requirements.txt lists all packages with pinned versions.
Use the GUI package manager
Use the GUI package manager
Replit provides a graphical interface for installing packages. Open the Dependencies tool from the Tools dock (or search for 'Packages' in the search bar). Type a package name in the search field to find it, then click the install button. The GUI detects your project type (Node.js, Python, etc.) and uses the appropriate package manager behind the scenes. This is useful when you want to browse packages without memorizing exact names or when you are new to the command line.
Expected result: Packages install via the GUI and appear in your dependency file. You can switch between GUI and Shell installation interchangeably.
Update and remove packages
Update and remove packages
Keeping packages updated prevents security vulnerabilities and ensures compatibility. Use npm update to update all packages to the latest versions allowed by your package.json version ranges. To remove a package you no longer need, use npm uninstall. For Python, use pip install --upgrade to update a specific package, and pip uninstall to remove one.
1# Node.js — update all packages2npm update34# Node.js — update a specific package5npm install express@latest67# Node.js — remove a package8npm uninstall unused-package910# Python — upgrade a package11pip install --upgrade flask1213# Python — remove a package14pip uninstall package-name1516# Python — regenerate requirements.txt after changes17pip freeze > requirements.txtExpected result: Packages are updated or removed. Dependency files (package.json, requirements.txt) reflect the current state of installed packages.
Configure automatic installation with onBoot
Configure automatic installation with onBoot
Set the onBoot command in your .replit file so dependencies install automatically whenever the Repl starts. This is especially important for team projects where collaborators should not need to manually run install commands after opening the project. Open .replit and add the onBoot line. For projects using both npm and pip, chain the commands.
1# .replit file23# Auto-install on startup4onBoot = "npm install"56# For Python projects:7onBoot = "pip install -r requirements.txt"89# For polyglot projects (both Node.js and Python):10onBoot = "npm install && pip install -r requirements.txt"Expected result: Opening the Repl automatically installs all dependencies. Collaborators do not need to run install commands manually.
Configure package installation for deployments
Configure package installation for deployments
Deployment builds run in a clean environment without pre-installed packages. You must include the install command in your [deployment] build step. Use npm ci (not npm install) for deployment builds because it installs exact versions from package-lock.json and is faster. Make sure package-lock.json or requirements.txt is committed to your project — without them, npm ci will fail.
1[deployment]2build = ["sh", "-c", "npm ci && npm run build"]3run = ["sh", "-c", "node dist/index.js"]4deploymentTarget = "cloudrun"Expected result: Deployment builds install all dependencies from the lock file before building and starting the app.
Complete working example
1{2 "name": "my-replit-project",3 "version": "1.0.0",4 "description": "A Replit project with managed dependencies",5 "main": "index.js",6 "scripts": {7 "start": "node index.js",8 "dev": "nodemon index.js",9 "build": "tsc",10 "test": "jest",11 "clean": "rm -rf dist node_modules",12 "reinstall": "npm run clean && npm install"13 },14 "dependencies": {15 "cors": "^2.8.5",16 "dotenv": "^16.3.1",17 "express": "^4.18.2"18 },19 "devDependencies": {20 "jest": "^29.7.0",21 "nodemon": "^3.0.2",22 "typescript": "^5.3.3"23 },24 "engines": {25 "node": ">=20.0.0"26 }27}Common mistakes when managing packages in Replit
Why it's a problem: Not committing package-lock.json to the project, causing npm ci to fail in deployments
How to avoid: Run 'npm install' in Shell to generate package-lock.json, then make sure it is included in your project files. Never add it to .gitignore.
Why it's a problem: Using npm install instead of npm ci in deployment builds
How to avoid: npm ci is faster and installs exact versions from the lock file. Use it in [deployment] build: build = ["sh", "-c", "npm ci && npm run build"].
Why it's a problem: Forgetting to regenerate requirements.txt after installing new Python packages
How to avoid: Run 'pip freeze > requirements.txt' after every pip install. This keeps the file synchronized with your actual environment.
Why it's a problem: Installing everything as a production dependency when some packages are dev-only
How to avoid: Use 'npm install --save-dev' for testing frameworks, linters, and build tools. This keeps production deployments lighter.
Why it's a problem: Not including npm install in the deployment build command, causing 'module not found' errors in production
How to avoid: Deployments start clean. Always include 'npm ci' as the first step in [deployment] build.
Best practices
- Always commit package-lock.json (npm) or requirements.txt (pip) to your project for reproducible builds
- Use --save-dev for packages needed only during development (test frameworks, build tools, linters)
- Use npm ci instead of npm install in deployment builds for faster, deterministic installations
- Set onBoot in .replit to auto-install packages when the Repl starts
- Run npm prune periodically to remove packages that are installed but no longer listed in package.json
- Pin critical package versions (express@4.18.2) instead of using ranges (express@^4) for stability
- Check storage usage in the Resources panel if node_modules grows large — Starter plan has ~2 GiB total
- For Python, always regenerate requirements.txt after installing or removing packages
Still stuck?
Copy one of these prompts to get a personalized, step-by-step explanation.
I'm building a Node.js project in Replit. How do I properly manage npm packages — installing, updating, removing, and making sure they are available in both development and deployment? I need package.json scripts and .replit configuration.
Set up package management for this project. Install Express, CORS, and dotenv as production dependencies. Install Jest and TypeScript as dev dependencies. Configure onBoot in .replit to auto-install. Set up the deployment build command with npm ci.
Frequently asked questions
Replit supports npm, pnpm, and yarn for Node.js; pip and poetry for Python; and the built-in GUI package manager for visual installation. Standard CLI tools are available in Shell.
No. node_modules persists across sessions. However, adding onBoot = "npm install" to your .replit file ensures any missing packages are restored automatically.
The ETARGET error means the version you requested does not exist in the npm registry. Check the package's available versions with 'npm view package-name versions' and use a valid version number.
Yes. Yarn and pnpm are available in Replit's Shell. Install them globally or add them to replit.nix. Update your .replit run command and onBoot to use the preferred package manager.
Add system-level dependencies to replit.nix using the pkgs. prefix. For example, pkgs.libvips for image processing or pkgs.postgresql for PostgreSQL. Run 'exit' in Shell after editing replit.nix.
Yes. Agent v4 automatically installs packages when building features. It updates package.json, requirements.txt, and replit.nix as needed. You can also prompt Agent directly: 'Install Express, CORS, and dotenv for this project.'
Deployments start with a clean environment. node_modules is not carried over. You must include npm ci or npm install in your [deployment] build command.
For projects with complex dependency trees and version conflicts, try npm ls to identify the conflict tree. If resolution becomes unwieldy, the RapidDev team can help diagnose and fix dependency issues that go beyond simple package management.
Talk to an Expert
Our team has built 600+ apps. Get personalized help with your project.
Book a free consultation