求助:jsdom使用时出现错误,错误内容如下:
发布于 9 年前 作者 cfltdf 5292 次浏览 最后一次编辑是 8 年前 来自 问答
C:\Work\NodeJS\node_modules\jsdom\lib\jsdom\level2\html.js:405
var nonInheritedTags = new Set([
                           ^
ReferenceError: Set is not defined
    at Object.<anonymous> (C:\Work\NodeJS\node_modules\jsdom\lib\jsdom\level2\html.js:405:28)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Module.require (module.js:364:17)
    at require (module.js:380:17)
    at Object.<anonymous> (C:\Work\NodeJS\node_modules\jsdom\lib\jsdom\living\index.js:8:1)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)

请问如何解决?

5 回复

多贴些你的代码。看不出来,需要context。

@leapon 我就写了 var jsdom=require(“jsdom”);

查了一下,jsdom 4.x 不支持 nodejs,支持 io.js 去了

Note that as of our 4.0.0 release, jsdom no longer works with Node.js™, and instead requires io.js. You are still welcome to install a release in the 3.x series if you use Node.js™.

用 3.x 吧

https://github.com/tmpvar/jsdom 的详细说明 nodejs 和 iojs 的分家把 npm 也搞分裂了,真是麻烦。

new Set es6语法node目前还不支持

回到顶部