Yarin
Yarin

Reputation: 183559

Client-side javascript error: Uncaught ReferenceError: require is not defined

I'm trying to create a new Range object in Ace Editor. I've found numerous examples prescribing the following:

var Range = require("ace/range").Range;
var newRange = new Range(0, 0, 0, 10);

But when I try this I get the following error:

Uncaught ReferenceError: require is not defined

I'm loading the Ace Editor JS in a script tag in a Rails view:

<script src="/js/ace_editor/ace.js" type="text/javascript" charset="utf-8"></script>

Upvotes: 0

Views: 1218

Answers (1)

a user
a user

Reputation: 24104

If you are using no-conflict version you need to use ace.require instead of require, since no-conflict doesn't create global require to not conflict with other incompatible implementations of require, that might be loaded on the page.

Upvotes: 1

Related Questions