Coding⏱️ 3 min read📅 2026-06-19

How to Fix: Apache Cordova throws syntax error when adding platform

Error fixing syntax issue with Cordova and Ionic Framework.

Quick Answer: Check the Cordova version and update it if necessary, then try adding platforms again.

Apache Cordova throws syntax error when adding platform

This issue affects users who are trying to install the iOS and Android platforms using Cordova.

It can be frustrating for developers, especially those who are new to Cordova or Ionic Framework.

In this guide, we will walk you through the steps to troubleshoot and fix the error.

💡 Why You Are Getting This Error

  • The error is caused by an incorrect version of Node.js being used with Cordova.
  • This issue can occur when the user has multiple versions of Node.js installed on their system.
  • The correct version of Node.js should be used to install Cordova.
  • Using the wrong version of Node.js can lead to compatibility issues and errors like the one described.

✅ Best Solutions to Fix It

Updating Node.js to the Correct Version

  1. Step 1: Step 1: Check the current version of Node.js being used on the system by running the command `node -v` or `npm -v`.
  2. Step 2: Step 2: Install the latest version of Node.js using the package manager for your operating system (e.g., `apt-get install nodejs` on Ubuntu-based systems).
  3. Step 3: Step 3: Verify that the correct version of Node.js has been installed by running the command `node -v` or `npm -v`.
  4. Step 4: Step 4: Try installing Cordova again using the command `sudo npm install -g cordova`.
  5. Step 5: Step 5: If the error persists, try updating the system's package list and then reinstalling Cordova.

Checking for Conflicting Packages

  1. Step 1: Step 1: Run the command `npm ls cordova` to check if any conflicting packages are installed.
  2. Step 2: Step 2: Uninstall any conflicting packages using the command `npm uninstall `.
  3. Step 3: Step 3: Try installing Cordova again using the command `sudo npm install -g cordova`.
  4. Step 4: Step 4: If the error persists, try deleting the Cordova package directory and then reinstalling it.

🎯 Final Words

To fix the Apache Cordova syntax error when adding platforms, update Node.js to the correct version or check for conflicting packages. Follow the steps outlined in this guide to troubleshoot and resolve the issue.

Did this fix your problem?

If not, try searching for specific error codes.

🔍 Search Error Database

❓ Frequently Asked Questions