尚未为上下文加载模块名称“stardog”:_。使用require([])

时间:2017-10-17 11:25:10

标签: javascript node.js requirejs stardog

我正在尝试使用Javascript来查询我的本地Stardog数据库。为此,我正在使用此处的代码:https://gist.github.com/ronmichael/4281566。我安装了npm,stardog,要求没有问题。但是,当我尝试运行以下代码时:

<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>

我在控制台中收到以下错误:

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.

据我所知,我正在以正确的方式使用require,因为我已经正确安装了stardog,它应该运行。任何人都可以指出我正确的方向我在这里做错了吗?

0 个答案:

没有答案