ionic tried calling but Cordova is not available


Got the error “Cordova is not available. Make sure to include cordova.js or run in a device/simulator” which looks like a bug. Found the answer on stackoverflow which is to update a project file (so needs to be done for each project):

From the above linked page:

The livereload plugin fails to serve cordova.js file and serves // mock cordova file during development.

FIX: You need go to node_modules/@ionic/app-scripts/dist/dev-server/serve-config.js

and replace

exports.ANDROID_PLATFORM_PATH = path.join('platforms', 'android', 'assets', 'www');

with

exports.ANDROID_PLATFORM_PATH = path.join('platforms', 'android', 'app', 'src', 'main', 'assets', 'www');

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.