jsdom document.createWindow()对非空文档返回空

我试图在https://github.com/tmpvar/jsdom下的“ 创build一个类似浏览器的BOM / DOM /窗口节的简短设置说明中。 不幸的是,在第三行(.createWindow步骤)后,我做了console.log(窗口),它打印一个空的对象。 那里应该至less有window.document,但是没有。 看起来好像document.createWindow和jsdom.createWindow一样。

这是我的代码到目前为止:

var jsdom = require('jsdom').jsdom; document = jsdom("<html><head></head><body>hello world</body></html>"); window = document.createWindow(); console.log(window); // output: {} console.log(window.document.innerHTML); // error, cannot read innerHTML on undefined 

那么,我做错了什么愚蠢的事情?

FYI文件正确创build。 打印它输出一个非常大的物体。

我正在使用Mac。

 var jsdom = require('jsdom').jsdom; document = jsdom('<!doctype html><html><body>hello jsdom</body></html>'); window = document.createWindow(); console.log(window); var txt = window.document.body.innerHTML; console.log(txt); 

问题是由于与Contextify的安装错误。 我习惯于在Windows或* NIX和Mac上开发,由于* NIXterminal,假设我会拥有像Make这样的东西。 通过安装Xcode和命令行工具解决了这个问题,它安装了Make等工具,解决了Contexify的安装错误,从而解决了整体问题。