How To Install Apache Cordova on Ubuntu 20.04 LTS
In this tutorial, we will show you how to install Apache Cordova on Ubuntu 20.04 LTS. For those of you who didn’t know, Apache Cordova is an open-source development framework for mobile devices that helps developers to use HTML5, CSS3, and JavaScript to build new mobile applications (iOS or Android). The platform includes a set of pre-built plugins to provide access to the camera, GPS, filesystem, and other components of the device.
This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo
‘ to the commands to get root privileges. I will show you the step-by-step installation of the Apache Cordova on Ubuntu 20.04 (Focal Fossa). You can follow the same instructions for Ubuntu 18.04, 16.04, and any other Debian-based distribution like Linux Mint.
Prerequisites
- A server running one of the following operating systems: Ubuntu 20.04, 18.04, 16.04, and any other Debian-based distribution like Linux Mint.
- It’s recommended that you use a fresh OS install to prevent any potential issues.
- SSH access to the server (or just open Terminal if you’re on a desktop).
- A
non-root sudo user
or access to theroot user
. We recommend acting as anon-root sudo user
, however, as you can harm your system if you’re not careful when acting as the root.
Install Apache Cordova on Ubuntu 20.04 LTS Focal Fossa
Step 1. First, make sure that all your system packages are up-to-date by running the following apt
commands in the terminal.
sudo apt update sudo apt upgrade sudo apt install python-software-properties
Step 2. Installing Node.js.
Apache Cordova required versions of both NodeJS and NPM. To install simply do:
curl -fsSL https://rpm.nodesource.com/setup_current.x | sudo bash -
Then, install Node.js using the following command:
sudo apt install nodejs
To check the version of Node.js installed, execute the command below:
nodejs -v
Next, run the command below to install the Node.js package manager:
sudo apt install npm
Step 2. Installing Apache Cordova on Ubuntu 20.04
By default, Apache Cordova is not available on Ubuntu 20.04 base repository. Now run the following command below to install Cordova using the npm:
sudo npm install -g cordova
Check the version of Apache Cordova has been installed:
cordova --version
Output:
? May Cordova anonymously report usage statistics to improve the tool over time? Yes Thanks for opting into telemetry to help us improve cordova. 11.0.0
Step 3. Creating Application With Cordova.
Once successfully installed, simply to start developing an application, you can follow the steps below:
cordova create myapp cd myapp cordova platform add android
Output:
Using cordova-fetch for cordova-android@~10.1.0 Adding android project... Creating Cordova project for the Android platform: Path: platforms/android Package: io.cordova.hellocordova Name: HelloCordova Activity: MainActivity Android target: android-27 Subproject Path: CordovaLib Subproject Path: app Android project created with cordova-android@10.1.0 Android Studio project detected Android Studio project detected Discovered plugin "cordova-plugin-whitelist" in config.xml. Adding it to the project Installing "cordova-plugin-whitelist" for android This plugin is only applicable for versions of cordova-android greater than 4.0. If you have a previous platform version, you do *not* need this plugin since the whitelist will be built in. Adding cordova-plugin-whitelist to package.json Saved plugin info for "cordova-plugin-whitelist" to config.xml --save flag or autosave detected Saving android@~10.1.0 into config.xml file ...
Congratulations! You have successfully installed Apache Cordova. Thanks for using this tutorial for installing the Apache Cordova on Ubuntu 20.04 LTS Focal Fossa system. For additional help or useful information, we recommend you check the official Apache website.