Skip to content

Cordova - Environment Setup

Setting up your development environment is the first step to building Cordova applications. This involves installing Node.js, the Cordova CLI, and platform-specific SDKs (Software Development Kits) if you plan to build for those platforms.

SoftwareDescription
Node.js and npmNode.js is a JavaScript runtime. Cordova uses it for its CLI and build processes. npm (Node Package Manager) is included with Node.js and is used to install Cordova and other packages. Download from nodejs.org.
Cordova CLIThe command-line tool for creating, building, and managing Cordova projects. Installed via npm.

To develop and build for specific mobile platforms, you’ll need their respective SDKs:

PlatformSDK & Requirements
AndroidAndroid SDK. This typically comes with Android Studio. You’ll need to install the SDK, configure environment variables (like ANDROID_HOME or ANDROID_SDK_ROOT), and ensure adb and other tools are in your system’s PATH. Refer to the official Android developer documentation.
iOS (macOS only)Xcode, which includes the iOS SDK, command-line tools, and simulator. Xcode is available from the Mac App Store. You may also need tools like ios-deploy (via npm) for deploying to devices.

Download and install Node.js LTS (Long Term Support) version from nodejs.org. This will also install npm.

Verify the installation by opening a new terminal or command prompt and typing:

node -v
npm -v

These commands should display the installed versions of Node.js and npm.

Cordova uses Git in the background to fetch and manage plugins, especially those from Git URLs. Even if you don’t use Git directly for your project, it’s good to have it installed. Download from git-scm.com.

Ensure Git is added to your system’s PATH during installation. You can verify by typing git --version in your terminal.

Install the Cordova CLI globally using npm. Open your terminal or command prompt and run:

npm install -g cordova

On macOS and Linux, you might need to prefix this command with sudo if you encounter permission errors: sudo npm install -g cordova.

Verify the Cordova installation by running:

cordova -v

This should display the installed Cordova CLI version.

Follow the official documentation for installing the SDKs for the platforms you want to target:

  • Android: Install Android Studio, then use the SDK Manager within Android Studio to install the necessary Android SDK Platforms and build tools. Set up environment variables like ANDROID_HOME (or ANDROID_SDK_ROOT) and add platform-tools and command-line tools to your PATH. See Cordova’s Android Platform Guide.
  • iOS (macOS only): Install Xcode from the Mac App Store. This will install the iOS SDK and related tools. You might also need to install command-line tools (xcode-select --install) and potentially ios-deploy (npm install -g ios-deploy). See Cordova’s iOS Platform Guide.

After installing everything, you can check if Cordova is ready to build for a specific platform. Navigate to a Cordova project directory (or create a new one with cordova create myApp) and run:

cordova requirements

This command will check for the necessary SDKs and tools for all installed platforms and report any issues.

With the environment set up, you are ready to create your first Cordova application!