将Tau-Prolog与Node.js结合使用

时间:2019-02-27 14:48:42

标签: javascript node.js prolog

下载Tau-Prolog之后,我尝试运行this example,但是突然被我停止了:

$ nodejs ./sample.js bread
/home/stefan/Desktop/tau-prolog/tau-prolog.js:6117
    pl.type.is_dom_object = function( obj ) {
       ^

TypeError: Cannot read property 'type' of undefined
    at /home/stefan/Desktop/tau-prolog/tau-prolog.js:6117:5
    at Object. (/home/stefan/Desktop/tau-prolog/tau-prolog.js:6382:3)
    at Module._compile (module.js:652:30)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
    at Function.Module._load (module.js:497:3)
    at Module.require (module.js:596:17)
    at require (internal/module.js:11:18)
    at Object. (/home/stefan/Desktop/tau-prolog/sample.js:2:10)

这是我当前的配置:

$ pwd
/home/stefan/Desktop/tau-prolog

$ ls
core.js  js.js        lists.js   sample.js      tau-prolog.js
dom.js   license.txt  random.js  statistics.js

$ uname -a
Linux stefan-TravelMate-B117-M 4.15.0-43-generic #46-Ubuntu SMP Thu Dec 6 14:45:28 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux

$ nodejs --version
v8.10.0

如何摆脱这个问题?


编辑

该问题似乎在最新版本的系统中消失了。

1 个答案:

答案 0 :(得分:2)

该示例具有用于导入tau-prolog.js的占位符路径:

var pl = require( "./path/to/tau-prolog.js" );

您需要将"./path/to/tau-prolog.js"替换为tau-prolog.js的实际路径,在您的情况下,该路径应仅为"./tau-prolog.js",因为该文件与样本位于同一目录中。试图运行。