Bench CLIBash

How to Create, Install, and Uninstall Apps in Frappe?

Create & Install App

Master the essential Bench CLI commands to create new custom apps, install them on your sites, and remove them safely when no longer needed.

In the Frappe ecosystem, 'Apps' are the building blocks of functionality. Whether you are building a completely new product or extending ERPNext, you will invariably need to create an app to house your code.

Unlike standard Python packages, Frappe apps are managed via the 'bench' command-line tool, which handles scaffolding, installation on specific sites (tenants), and uninstallation. Understanding this lifecycle is critical for any Frappe developer.

1# 1. Create a new app
2bench new-app my_custom_app
3
4# 2. Install the app on a specific site
5bench --site site_name install-app my_custom_app
6
7# 3. Uninstall the app from a site
8bench --site site_name uninstall-app my_custom_app

Understanding This Code

What It Does

These commands allow you to manage the full lifecycle of a Frappe application. 'new-app' generates the folder structure and boilerplate code. 'install-app' runs the database migrations to create DocTypes and tables for the site. 'uninstall-app' removes the app's tables and data from the site.

When To Use

Use these commands when starting a new project, deploying a custom module to a particular site, or cleaning up unused apps to free up resources.

Prerequisites

  • A running Bench instance.
  • Access to the terminal/command line.
  • A valid site created (e.g., via 'bench new-site').

Key Concepts

Important ideas to understand in this code

Bench CLI

Bench is the command-line utility used to manage Frappe deployments. It handles everything from creating sites and apps to updating the system and running maintenance tasks.

Learn more

Sites (Multi-tenancy)

Frappe supports multi-tenancy, meaning a single codebase (bench) can serve multiple websites (sites). Apps must be explicitly installed on each site where they are needed.

Learn more

App boilerplate

When you run 'bench new-app', Frappe automatically creates a standard directory structure including setups for modules, hooks, public assets, and tests, ensuring best practices are followed from the start.

Learn more

Step-by-Step Tutorial

Follow along to understand how this code works

1

Create the App

Run the 'new-app' command. You will be prompted for details like the App Title and Description. This command creates a new folder in the 'apps' directory.

bash
bench new-app library_management
Next Step
2

Install App on Site

Creating the app downloads the code, but doesn't activate it for any site. To use the app, install it on your target site. This process creates the necessary database tables.

bash
bench --site my.site.name install-app library_management
Next Step
3

Verify Installation

You can verify that the app is installed by checking the 'site_config.json' or simply listing the installed apps for the site.

bash
bench --site my.site.name list-apps
Next Step
4

Uninstall App (If needed)

If you need to remove the app and its data from a specific site, use the 'uninstall-app' command. WARNING: This will delete all data related to that app from the site's database.

bash
bench --site my.site.name uninstall-app library_management

Common Issues & Solutions

Troubleshoot problems you might encounter

Talk to our Experts

Ready to Scale with Smart Tech? Let's Talk.

Transform your business processes with AI-powered automation and expert implementation.

Trusted by 100+ businesses

Frequently Asked Questions

Find answers to common questions about our services

Still have questions?

Contact Support

Book a Free Consultation

Get started with your free demo today and discover how our solutions can transform your business

Quick Response
Free Consultation

Get Started Today

Fill out the form below and we'll get back to you within 24 hours

By submitting this form, you agree to our privacy policy and terms of service.