Guides 11792 Published by

Installing Apache Cordova on Debian 11 begins with adding a current NodeSource repository so that you can install Node 18 and its bundled npm, which are required for the latest Cordova CLI to resolve dependencies correctly. After verifying the Node installation, you globally install the Cordova package with npm, then set up Java by installing OpenJDK‑11 and download the Android command‑line tools, configuring your PATH so that adb and build tools are available for native builds. With those pieces in place you can create a test project, add the Android platform, and run a release build that outputs an APK in the platforms directory; the process will succeed only if the SDK components and JAVA_HOME environment variable point to the correct locations. The guide also lists common stumbling blocks such as missing adb, permission errors on node_modules, or mismatched Java versions, offering quick fixes so you can keep your build pipeline running smoothly.



Installing Apache Cordova on Debian 11

If you’re trying to get your first hybrid app off the ground and you’ve settled on Debian 11, this quick walk‑through will have Cordova up and running in under an hour. You’ll learn which packages are mandatory, how to avoid the common “node‑not‑found” mess, and a few tricks for keeping things tidy.

. Get Node.js & npm (the backbone of Cordova)

Debian’s own repos ship Node 10, which is too old for Cordova 11+. I’ve seen projects break when you try to install the CLI with that version because npm can’t resolve newer package dependencies.

1. Add the NodeSource repo – this gives you the latest LTS (currently Node 18).

   curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash -

2. Install Node & npm

   sudo apt-get install -y nodejs

3. Confirm the version – a quick sanity check.

   node --version && npm --version

> Cordova’s CLI is built on npm modules that rely on modern JavaScript features. Using an outdated Node breaks those dependencies and leaves you staring at cryptic stack traces.

. Install the Cordova CLI

Once Node is healthy, grab Cordova from npm.

sudo npm install -g cordova
  • -g installs it system‑wide so you can run cordova from any folder.
  • I’ve seen people hit permission errors when they try to use a local install; the global route sidesteps that.

Verify:

cordova --version
. Set up Java and Android SDK (needed for building native wrappers)

Cordova talks to the Android build tools, so you need a JDK and the SDK command‑line tools.

1. Install OpenJDK – Debian’s default is fine.

   sudo apt-get install -y openjdk-11-jdk

2. Download the Android SDK Command Line Tools (skip if you already have Android Studio).

   mkdir -p ~/Android/Sdk/cmdline-tools
   cd ~/Android/Sdk/cmdline-tools
   wget https://dl.google.com/android/repository/commandlinetools-linux-8512546_latest.zip
   unzip commandlinetools-linux-*.zip

3. Add SDK to your PATH – add these lines to ~/.bashrc or ~/.zshrc.

   export ANDROID_SDK_ROOT=$HOME/Android/Sdk
   export PATH=$PATH:$ANDROID_SDK_ROOT/cmdline-tools/tools/bin
   export PATH=$PATH:$ANDROID_SDK_ROOT/platform-tools

4. Install SDK packages – this pulls in the platform tools, build tools, and an Android API level.

   sdkmanager "platforms;android-33" "build-tools;33.0.2"

> Without adb and the correct build tools, cordova run android will just hang or spit out “No SDK found” messages.

. Create a test project
cordova create hello com.example.hello HelloCordova
cd hello
cordova platform add android

If everything is wired correctly, you should see:

Adding Android...
   ... (lots of progress output) ...
   Android platform added successfully.

Build it:

cordova build android --release

A successful build creates an APK in platforms/android/app/build/outputs/apk/release.

. Common pitfalls and quick fixes
  • adb: command not found – make sure you sourced your shell profile after adding the SDK to PATH.
  • Permission denied on /usr/lib/node_modules – if you ran into this, delete that folder and reinstall Cordova with sudo npm install -g cordova --unsafe-perm.
  • “Failed to find target” error – double‑check you installed an Android platform (sdkmanager "platforms;android-33").
  • Java version mismatch – I’ve seen the Android build tools complain if JAVA_HOME points at a JRE instead of a JDK. Run echo $JAVA_HOME; if it’s empty, point it to /usr/lib/jvm/java-11-openjdk-amd64.
. Wrap‑up

You now have a working Apache Cordova installation on Debian 11, complete with Android build support. From here you can add iOS (with a Mac or via the Expo bridge), install plugins, and start hacking away at your cross‑platform app.