1

I'm trying to use Javascript for querying my local Stardog database. To do this, I'm using the code from here: https://gist.github.com/ronmichael/4281566. I've installed npm, stardog, require without problems. However, when I try to run the following code:

<html>
<head>
    <link rel="stylesheet" href="css/bootstrap.css">
    <link rel="stylesheet" href="css/main.css">
    <script src="js/require.js"></script>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>

</head>



<script>
    const { Connection, query } = require('stardog');

    const conn = new Connection({
      username: 'admin',
      password: 'admin',
      endpoint: 'http://localhost:5820',
    });

    query.execute(conn, 'select distinct ?s where { ?s ?p ?o }', {
      limit: 10,
      offset: 0
    }).then(({ result }) => {
      console.log(result.results.bindings);
    });
</script>


<script src="js/jquery.min.js"></script>
<script src="js/jquery.js"></script>
<script src="js/bootstrap.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src="js/main.js"></script>

I get the following error in my console:

Uncaught Error: Module name "stardog" has not been loaded yet for context: _. Use require([])
http://requirejs.org/docs/errors.html#notloaded
    at F (require.js:7)
    at Object.m [as require] (require.js:26)
    at requirejs (require.js:32)
    at (index):22.

As far as I'm aware, I'm using require in the right way and since I've installed stardog properly, it should run. Could anyone point me in the right direction what I'm doing wrong here?

Edit: answer can be found here: Karma unit testing: Module name "react" has not been loaded yet for context: _. Use require([])

sander
  • 1,340
  • 1
  • 10
  • 20
  • What `require` are you using? To use node modules on the client-side you look here https://stackoverflow.com/questions/4944863/how-to-use-node-js-module-system-on-the-clientside – Tobias Timm Oct 17 '17 at 11:29
  • RequireJS is not a drop-in replacement for a CommonJS loader. Just doing `const { Connection, query } = require('stardog');` won't work, as RequireJS does not directly support that form of `require`. See the answer on the question against which I closed this one for details. – Louis Oct 17 '17 at 11:40

0 Answers0