Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cordova plugin error: "Uncaught module ... already defined"

I was getting the following error and my custom plugin wasn't starting.

"Uncaught module com.example.example-plugin already defined"

Why is my module getting defined twice?

like image 290
akiraspeirs Avatar asked Oct 30 '15 06:10

akiraspeirs


1 Answers

This error occurred because I copy-pasted code from the generated 'example-plugin.js' back into the original plugin file.

When I added the plugin again, the generated code then got wrapped twice like this:

cordova.define("com.example.example-plugin", function(require, exports, module) { cordova.define("com.example.example-plugin", function(require, exports, module) { var exec = require('cordova/exec');

Removing the generated bits from the original example-plugin.js file fixed this.

like image 114
akiraspeirs Avatar answered Sep 18 '22 20:09

akiraspeirs