Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Installing Zombie.js Error: ReferenceError: Set is not defined. What am I doing wrong?

Background: I'm currently reading "Web Development with Node and Express" by Ethan Brown (great book by the way for those learning node and express) and I got stuck on Chapter 5 - Quality Insurance.

Everything was running smooth. First I ran the following:

npm install --save-dev mocha

npm install -g mocha

npm install --save-dev chai

npm install --save-dev zombie

Problem: Then I ran (as the book instructed):

mocha -u tdd -R spec qa/tests-crosspage.js 2>/dev/null

But this wasn't doing anything. So then I ran:

mocha -u tdd -R spec qa/tests-crosspage.js

And then this error appeared:

/Users/esanz91/Desktop/CodingNotes/Node/MySite/node_modules/zombie/node_modules/jsdom/lib/jsdom/level2/html.js:405 var nonInheritedTags = new Set([

ReferenceError: Set is not defined

Versions: Just to give you guys an idea, I have the following versions installed.

cmd:

npm list --depth=0

results:

├── [email protected]

├── [email protected]

├── [email protected]

├── [email protected]

└── [email protected]

Also, I'm running on Node 0.10.

How can I fix this issue?

Thanks!

like image 689
esanz91 Avatar asked Apr 15 '15 23:04

esanz91


People also ask

How do you fix ReferenceError require is not defined?

To solve the "ReferenceError require is not defined" error, remove the type property if it's set to module in your package. json file and rename any files that have a . mjs extension to have a . js extension.

What does it mean when something is not defined in JavaScript?

The JavaScript exception "variable is not defined" occurs when there is a non-existent variable referenced somewhere.

How do I fix reference error in JavaScript?

Reference errors in Javascript are mainly thrown when an attempt is made to reference a variable that does not exist or is out of scope. Therefore, in the majority of cases, a ReferenceError can be fixed by making sure that the referenced variable is defined correctly and is being called in the correct scope.

Is not defined in JS error?

A not defined error is when we did not declare the variable and tried to call that variable. In JavaScript, we can declare variables without adding const , let , or var , and we won't get an error of undefined or not defined .


1 Answers

I found the answer to my own question. I actually needed to downgrade Zombie 4.0.7 to 3.1.x so that the mocha test command could work with Node 0.10.

Edit1: I decided to upgrade my Node version to 0.12 and my Zombie version back up to 4.0.7 and that worked too. (seems like Node 0.10 and Zombie 4.0.7 not compatible...)

Edit2: For anyone reading the book, I suggest looking at the github repo by the author himself. Take a look at the package.json file to see which version of the modules he uses.

like image 161
esanz91 Avatar answered Oct 12 '22 20:10

esanz91