简体   繁体   English

“TypeError: jsdom.jsdom is not a function” with paper-node.js in npm paper 模块

[英]"TypeError: jsdom.jsdom is not a function" with paper-node.js in npm paper module

I have installed webppl-agents library (along with webppl and webppl-dp ) and am trying to run the command line test, but I'm running into some trouble.我已经安装了webppl-agents库(以及webpplwebppl-dp )并且正在尝试运行命令行测试,但是我遇到了一些麻烦。 It appears there is a dependency issue with jsdom from the npm paper module (1) (2) (3) (4) , but I haven't been able to get a complete handle on the issue at this point. npm 文件模块(1) (2) (3) (4) 中的jsdom 似乎存在依赖性问题,但此时我无法完全处理该问题。

Does anybody know what's going on here?有人知道这里发生了什么吗? Do I just need to use a newer version of paper?我是否只需要使用较新版本的纸张?

 PS C:\Users\user\.webppl\node_modules\webppl-agents> webppl --require webppl-dp --require . tests/tests.wppl
C:\Users\user\.webppl\node_modules\webppl-agents\node_modules\paper\dist\paper-node.js:10835
        document = jsdom.jsdom('<html><body></body></html>'),
                         ^

TypeError: jsdom.jsdom is not a function
    at new <anonymous> (C:\Users\user\.webppl\node_modules\webppl-agents\node_modules\paper\dist\paper-node.js:10835:19)
    at Object.<anonymous> (C:\Users\user\.webppl\node_modules\webppl-agents\node_modules\paper\dist\paper-node.js:33:13)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)

    at Function.Module._load (module.js:438:3)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (C:\Users\user\.webppl\node_modules\webppl-agents\src\visualization\gridworld.js:1:75)

There has been some breaking changes recently.最近发生了一些重大变化。 The following way of initializing jsodm , document and window fixed it for me:以下初始化jsodmdocumentwindow为我修复了它:

import jsdom from 'jsdom';  
const {JSDOM} = jsdom;  
const {document} = (new JSDOM('<!doctype html><html><body></body></html>')).window;  
global.document = document;  
global.window = document.defaultView;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM