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

Using Tau-Prolog with Node.js

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

我怎样才能摆脱这个问题?


编辑

使用最新版本的系统似乎问题消失了。

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

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

您需要将 "./path/to/tau-prolog.js" 替换为 tau-prolog.js 的实际路径,在您的情况下,该路径应该只是 "./tau-prolog.js",因为该文件与您尝试 运行.

的样本