cli/README.md
The Capacitor command-line interface (CLI) is a tool for creating and managing Capacitor applications. While it can be installed globally, it's recommended to install it locally in your project and execute through npm scripts.
Install the CLI locally in your project:
npm install @capacitor/cli --save-dev
While not recommended for project use, you can install the CLI globally:
npm install -g @capacitor/cli
The CLI can be used through the capacitor or cap command. When installed locally, use it through your project's npm scripts or npx.
Common commands:
cap init: Initialize a new Capacitor projectcap add: Add a native platform (ios, android)cap sync: Sync your web code to your native projectsFor detailed information, consult the Getting Started guide.
If you're contributing to the Capacitor CLI or testing local changes:
Clone and setup:
git clone https://github.com/ionic-team/capacitor.git
cd cli
npm install
Build the CLI:
npm run build
Create a local link:
npm link
Development workflow:
npm run watch to automatically rebuild on changescapacitor or cap commands to test your changesnpm test to execute the test suiteThe CLI includes VS Code launch configurations for debugging. To debug a CLI command:
You can add more configurations by copying and modifying the existing ones in .vscode/launch.json.
Contributions are welcome! Please read our Contributing Guide for details.