Skip to content


Subversion checkout URL

You can clone with
Download ZIP


Cannot read property 'implementation' of undefined #436

SunboX opened this Issue · 51 comments
    features   = JSON.parse(JSON.stringify(window.document.implementation._fea

TypeError: Cannot read property 'implementation' of undefined
    at /shared/users/xxx/node_modules/jsdom/lib/jsdom.js:171:59
    at Request._callback (/shared/users/xxx/node_modules/jsdom/lib/jsdom.js:275:9)
    at Request.callback (/shared/users/xxx/node_modules/request/main.js:119:22)
    at Request.<anonymous> (native)
    at Request.emit (events.js:70:17)
    at Request. (/shared/users/xxx/node_modules/request/main.js:521:16)
    at Request.emit (events.js:67:17)
    at IncomingMessage. (/shared/users/xxx/node_modules/request/main.js:483:14)
    at IncomingMessage.emit (events.js:88:20)
    at HTTPParser.onMessageComplete (http.js:137:23)

Seeing same problem as I run the main sample:

features   = JSON.parse(JSON.stringify(window.document.implementation._fea

TypeError: Cannot read property 'implementation' of undefined
at C:\Program Files\nodejs\node_modules\jsdom\lib\jsdom.js:171:59
at Request._callback (C:\Program Files\nodejs\node_modules\jsdom\lib\jsdom.js:275:9)
at Request.callback (C:\Program Files\nodejs\node_modules\request\main.js:119:22)
at Request. (C:\Program Files\nodejs\node_modules\request\main.js:525:16)
at Request.emit (events.js:67:17)
at IncomingMessage. (C:\Program Files\nodejs\node_modules\request\main.js:4
at IncomingMessage.emit (events.js:88:20)
at HTTPParser.onMessageComplete (http.js:137:23)
at Socket.ondata (http.js:1150:24)
at TCP.onread (net.js:354:27)


Reported also at:
I've download the project and tried to execute the tests, they seem to fail as well.
Looking at the latest code changes in the project I can't seem to figure out when this has happened.
This happens with both node 0.6.11 and 0.6.15.


I am experiencing the same problem on mac osx


weird, I can't seem to dupe with the code from SO.


I´ve gotten this failure on ´s online test. Don´t know the node version running there


I too am running into this issue, on node v0.6.15.


what version of jsdom are you guys running?


Mine is showing latest - 0.2.14.


Same, 0.2.14, installed via npm. Here's a test script which yields the error:


Same bug, both with node 0.6.15, 0.7.8 and jsdom 0.2.14.
Edit: on win7 64bits, also can trigger it with the script of philip-peterson


It looks like this has something to do with the Contextify workaround. I can reproduce this without Contextify, but not with it. Contextify should build on Windows now, so try installing that.


Having the same with this test case:

var fs             = require('fs'),
    jsdom          = require('jsdom'),
    xpath          = require('./node_modules/jsdom/lib/jsdom/level3/xpath.js'),
    XPathResult    = xpath.XPathResult,
    XPathEvaluator = new xpath.XPathEvaluator();

for (var x = 1; x <= 4; x++) {    
        html : '' + x + '&page=0&mode=Crystal',
        done: function (err, window) {
            if (err) {
                console.log('Error caught at', err);
            } else {
                var context  = window.document,
                    xpathStr = '/html/body/div[1]/div[2]/table[1]/tr/td[2]/table/tr[2]/td',
                    result   = XPathEvaluator.evaluate(xpathStr, context, context, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE);

                console.log('Results count: ', result.snapshotLength);
                console.log('Result textContent', result.snapshotItem(0).textContent);
        features: {
            FetchExternalResources   : [],
            ProcessExternalResources : false,
            MutationEvents           : false,
            QuerySelector            : false

It should be noted that i do NOT have Contextify on this computer, since I'm not gonna install Python for this sole app.


After digging around the issue is in fact related to Contextify.
If Contextify is missing / cannot be installed then this error pops up.

contextify is having a problem because it tries to build bindings using the 'node-bindings' tool, which then uses 'node-gyp' which doesn't support Python 2.4, it seems.

What version of Python do you all have installed?


I've got "Python 2.7.2+"


2.7.2, Windows distribution.


Just installed Python 2.3.5. Its currently compiling Contextify, ill keep you in touch and edit when the process either fails or successes.


Console output:

C:\Program Files\nodejs>npm install jsdom
npm http GET
npm http 304
npm http GET
npm http GET
npm http GET
npm http 304
npm http 304
npm http 304
npm http GET
npm http 304

> contextify@0.1.2 install C:\Program Files\nodejs\node_modules\jsdom\node_modul
> node-gyp rebuild

C:\Program Files\nodejs\node_modules\jsdom\node_modules\contextify>node "C:\Prog
ram Files\nodejs\node_modules\npm\bin\node-gyp-bin\\..\..\node_modules\node-gyp\
bin\node-gyp.js" rebuild
info it worked if it ends with ok
spawn python [ 'C:\\Users\\perquet\\.node-gyp\\0.6.15\\tools\\gyp_addon',
  '-IC:\\Program Files\\nodejs\\node_modules\\jsdom\\node_modules\\contextify\\b
  'msvs_version=2010' ]
Traceback (most recent call last):
  File "C:\Users\perquet\.node-gyp\0.6.15\tools\gyp_addon", line 14, in ?
    import gyp
  File "C:\Users\perquet\.node-gyp\0.6.15\tools\gyp\pylib\gyp\", line
 8, in ?
    import gyp.input
  File "C:\Users\perquet\.node-gyp\0.6.15\tools\gyp\pylib\gyp\", line 14
, in ?
    import gyp.common
  File "C:\Users\perquet\.node-gyp\0.6.15\tools\gyp\pylib\gyp\", line 1
SyntaxError: invalid syntax
ERR! Error: `gyp_addon` failed with exit code: 1
    at Array.0 (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\l
    at EventEmitter._tickCallback (node.js:192:40)
ERR! not ok
npm WARN optional dependency failed, continuing contextify@0.1.2
jsdom@0.2.14 ./node_modules/jsdom
├── cssom@0.2.3
└── request@2.9.202

I'm on window 7 32 bits.


Any quick fixes? What version of node / jsdom should I install to get it running?

OSX 10.6.8
node --version

npm view jsdom
latest: '0.2.14'

python --version
Python 2.6.1

    features   = JSON.parse(JSON.stringify(window.document.implementation._fea
TypeError: Cannot read property 'implementation' of undefined
    at /Users/user1/node_modules/jsdom/lib/jsdom.js:171:59
    at Object.env (/Users/user1/node_modules/jsdom/lib/jsdom.js:262:5)
    at Request._callback (/Users/user1/Dropbox/Projects/NodeScraper/app.js:45:13)
    at Request.callback (/Users/user1/Dropbox/Projects/NodeScraper/node_modules/request/main.js:119:22)
    at Request.<anonymous> (native)
    at Request.emit (events.js:70:17)
    at Request.<anonymous> (/Users/user1/Dropbox/Projects/NodeScraper/node_modules/request/main.js:521:16)
    at Request.emit (events.js:67:17)
    at IncomingMessage.<anonymous> (/Users/user1/Dropbox/Projects/NodeScraper/node_modules/request/main.js:483:14)
    at IncomingMessage.emit (events.js:88:20)```

This actually is a contextify issue. I'm trying to install it with various versions of Python, ranging from 2.3.5 to 2.7.2


I am also having trouble with this:
OSX 10.7.3
Node 0.6.10
JSDom 0.2.14



Any news on this. I am just starting with node.js and jsdom today and this is a nice 'howdoyado'. :-)


I just installed node 0.6.16 today and used npm to install everything else.

npm ls gives me

├─┬ http-agent@0.1.2
│ └── request@1.9.9
├─┬ jquery@1.7.2
│ ├── htmlparser@1.7.6
│ ├─┬ jsdom@0.2.14
│ │ └── cssom@0.2.3
│ └── xmlhttprequest@1.3.0
├─┬ jsdom@0.2.14
│ ├── cssom@0.2.3
│ └── htmlparser@1.7.6
└── request@2.9.202


Hey everyone, I just ran into this error today and solved it.

All I did was install Python 2.7.3 (recommended by Contextify) and added my environment variables (PYTHONPATH, and added C:\Python27 to the end of my PATH variable).

I then reinstalled jsdom.

After that I ran the README test again and it worked!


awesome! thank you for looking into this @kamranayub!


Confirmed, working fix. Thanks a lot :)


Doesn´t work for me. :( I can´t install Python on ... :(


This just doesn't make any sense. I just started with Nodejs a couple of days ago and am trying to work my way trying to build something. I required jsdom and it doesn't work at all due to contextify. Its a little early to start with something and end up fixing build errors :)
nodejs version - v0.6.18
jsdom - 0.2.14
Python - 2.7.3
I get the same error as warpten and stefek99. Please help.


Follow @kamranayub 's tip.


That didn't seem to work work for me, but this helped.
npm install contextify -f
after installing Microsoft Visual Studio Express edition.


Just wanted to mention that you could look at Cheerio if you didn't need all the fanciness of jsdom:


Thanks! Cheerio looks good. I was in a bit of a hurry for setting up a prototype, so has to move to the express+jade combo. I will give Cheerio a shot now :)


So there is no way to use jsdom without contextify at the moment? That's a pity, but thanks for the pointer to cheerio!


Ran into the same issue. sudo npm install contextify in the project using jsdom worked for me.


I have this issue as well. I think I've tried all of the above to some extent, although I might have missed one. Here are my stats:

Ubuntu 12.04
Python 2.7.3
Node v0.8.0
jsdom 0.2.15
contextify 0.1.3
request 2.10.0

Any other suggestions?


Same issue on Windows 7 (64 bits) with Node v0.8.4.
Thankfully I have been able to replace the "jsdom" + "jQuery" combo with "Domino" + "Zepto Node" , which are 100% JavaScript libraries.


I didn't have this issue until after I updated Node from v0.8.2 (I think) to v0.8.9 on my Win7 computer.

Python 2.7.3
Node 0.8.9
jsdom 0.2.15
-> contextify 0.1.3
request 2.10

I'm attempting to roll back my version of node to see if I can get it to work again without switching over to Domino/Zepto.


Thanks @DrBenton for the suggestion. Had to rely on Domino and Zepto Node to work around this for now.


This is a dupe of #456, and more evidence toward Contextify not being optional.

@domenic domenic closed this
@mennovanslooten mennovanslooten referenced this issue in keeganstreet/element-finder

Replace JSDOM and Sizzle with Cheerio #3


On MacOS 10.8. Installed fresh Xcode and brew, python. Contextify fails to build.
This fixed for me.
export PATH=/Applications/$PATH
sudo ln -s /Applications/ /usr/include
sudo ln -s /Applications/* /usr/lib/
npm install contextify

@jonahkagan jonahkagan referenced this issue in lhagan/wintersmith-showdown

Error installing with Python >= 3 #1


im sorry but this api is broke and this is the first api you find when you search for node.js jquery. as drbrenton pointed out domino + zeptune will get it done.


Yes, you need to be able to install native modules. If you're using Windows, that means Python + Visual Studio 2010 Express + a 32-bit version of Node. I know it sucks, but that's how Node.js works.


how to solve this problem?


@niued install the very latest jsdom version, with Contextify.

@mhhansen mhhansen referenced this issue in ecdeveloper/node-web-crawler

Cannot read property 'implementation' of undefined #3


Don't know if this helps - but we were able to solve this by using contextify 0.1.3 instead of the latest. Since JSDOM is pointing at contextify 0.1.x it's pulling in 0.1.5 - which seems to be causing the problem (at least for us)

@civild civild referenced this issue in ryanflorence/ember-tools

Problem with ember build #23


fwiw, I have this problem on ubuntu


@nickgeorge, what version of jsdom/node/npm, and do you get any errors when installing jsdom? What does npm ls list?


After having things work fine for a number of months with jsdom 0.4.1 and node 0.8.(approx 16?), I started receiving this error today, also. I had just upgraded to node 0.10.3 (latest).

Issuing "npm update" has fixed things. Now running (on Ubuntu 10.04):

  • jsdom 0.4.2
  • contextify 0.1.5



I'm having this problem too.

@gordonwritescode how did you override the version of contextify inside jsdom to 0.1.3?

Versions of things I have are:

├─┬ jsdom@0.3.4 
│ ├─┬ contextify@0.1.5 
│ │ └── bindings@1.1.0 
│ ├── cssom@0.2.5 
│ ├── cssstyle@0.2.3 
│ └── nwmatcher@1.3.1 
# node -v
# npm -v

Aha! I've found a workaround for me. Which is to install version 0.5.4 of jsdom, after having already installed contextify 0.1.3 gobally. Like this:

npm install contextify@0.1.3; npm remove jsdom; npm install jsdom@0.5.4

It seems that 0.5.4 of jsdom was the one that changed from contextify@0.1.x to contextify@0.1.5


I too find a workaround for this. I rebuild my npm-shrinkwrap with contextify in first in my package.json dependencies.

"dependencies" : {

So deleting my node-modules directory and my npm-shrinkwrap.json and then

npm shrinkwrap


npm install

Even though it's 2 years later, thanks @kamranayub for your comments. I don't have root access on the box I'm running this on and so I couldn't upgrade the version of python. The HTML I was parsing was static so Cheerio was a perfect fit for me. You've saved me tons of dev time!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.