eclipse Orion ReferenceError: require is not defined

177 Views Asked by At

There's an editor eclipse Orion that allows for editing source codes in various languages in a web browser. An instruction says the editor can be set up through these few lines of HTML code.

<link rel="stylesheet" type="text/css" href="http://eclipse.org/orion/editor/releases/4.0/built-editor.css"/>
<script src="http://eclipse.org/orion/editor/releases/4.0/built-editor.min.js"></script>
<script>
/*global require*/
require(["orion/editor/edit"], function(edit) {
    edit({className: "editor"});
});
</script>

I pasted these lines into an editor, adapted the paths of the included .css and .js files and called the page in a web browser. It results in the error Uncaught ReferenceError: require is not defined.

There's an alternative instruction that says to include the -amd version of the eclipse Orion JS files and to also include a certain require.js JS file. Am I missing something or is the instruction missing the hint to always include require.js to provide the require function?

The instruction is a few years old. I'm using recent Orion build 14.3. Has something changed over the years? Has the require function been provided once in an earlier build?

1

There are 1 best solutions below

0
Stefan On

Yes, requirejs needs to be included, for example with

<script src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.5/require.js></script>

If you installed requirejs with bower you might want to use something like

<script src="./bower_components/requirejs/require.js"></script>

Also see the sourcode of following working Orion example:

http://libingw.github.io/OrionCodeEdit/