Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ACE editor dropping module because define wasn't a string

I'm using ace editor in a project. I'm trying to create a HightLight, following the tutorial in Higlighter section on ace editor page, but when I use this code:

define(function(require,exports,module){
        //any code here
});

I get this error in the web console:

dropping module because define wasn't a string.

Does anyone know why it happens?

like image 773
jircdeveloper Avatar asked May 13 '16 16:05

jircdeveloper


1 Answers

Ace defines a global function called define, and that function is what is producing the error.

If you have any other JS libraries (particularly CommonJS or AMD modules) that call define, they will end up calling the Ace version if Ace is loaded before they are.

In my case, I had a JS file produced by Browserify that included a bunch of Node modules, and one of those was calling define with an empty array instead of a string for the module param. And because it was included after the Ace script file, it was using the Ace version of define, which complained with the error message in question.

Changing the order of your script includes may fix this (move your other module-based script includes above the Ace script include). That worked for me.

like image 69
BobDickinson Avatar answered Sep 24 '22 00:09

BobDickinson