Ace editor "define is not defined"

If you already have the source, then it is pretty easy to do still. Just go in the directory where you copied all the ace source.

Then, do:

npm install
node Makefile.dryice.js

See the wiki for additional details https://github.com/ajaxorg/ace/wiki/Building-ace


I hacked it by putting window.define = ace.define; in my DOMload handler.


You are getting this error because the RequireJS JavaScript library has not been included in your page.

To fix this either use an ace build or include RequireJS in your page.

If you choose to include RequireJS your html fragment will look something like this:

<!-- Editor will go here -->
<div id="editor"></div>

<!-- Load RequireJS -->
<script src="lib/requirejs/require.js"></script>

<!-- Initialize ace -->
<script>

    // Tell RequireJS where ace is located
    require.config({
        paths: {
            'ace': 'lib/ace'
        }
    });

    // Load the ace module
    require(['ace/ace'], function(ace) {
        // Set up the editor
        var editor = ace.edit('editor');
        editor.setTheme('ace/theme/monokai');
        editor.getSession().setMode('ace/mode/javascript');
        // etc...
    });
</script>