Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot read property 'implementation' of undefined #436

Closed
SunboX opened this issue Apr 11, 2012 · 51 comments
Closed

Cannot read property 'implementation' of undefined #436

SunboX opened this issue Apr 11, 2012 · 51 comments

Comments

@SunboX
Copy link

SunboX commented Apr 11, 2012

/shared/users/xxx/node_modules/jsdom/lib/jsdom.js:171
    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)
@AvnerCohen
Copy link

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
84:14)
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)

@AvnerCohen
Copy link

Reported also at: http://stackoverflow.com/questions/10143288/node-js-jsdom-error
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.

@ejohann
Copy link

ejohann commented Apr 17, 2012

I am experiencing the same problem on mac osx

@tmpvar
Copy link
Member

tmpvar commented Apr 17, 2012

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

@SunboX
Copy link
Author

SunboX commented Apr 17, 2012

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

@philip-peterson
Copy link

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

@tmpvar
Copy link
Member

tmpvar commented Apr 18, 2012

what version of jsdom are you guys running?

@AvnerCohen
Copy link

Mine is showing latest - 0.2.14.

@philip-peterson
Copy link

Same, 0.2.14, installed via npm. Here's a test script which yields the error: https://github.com/philip-peterson/propellant/blob/c5bac2cc21fe3c38090d001bba09c78037378fe7/test.js

@slurdge
Copy link

slurdge commented Apr 19, 2012

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

@brianmcd
Copy link
Contributor

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.

@Warpten
Copy link

Warpten commented Apr 20, 2012

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++) {    
    jsdom.env({
        html : 'http://sapphiretrans.free.fr/Pokedex/?act=' + 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.

@trevoro
Copy link

trevoro commented Apr 20, 2012

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?

@philip-peterson
Copy link

I've got "Python 2.7.2+"

@AvnerCohen
Copy link

2.7.2, Windows distribution.

@Warpten
Copy link

Warpten commented Apr 21, 2012

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

@Warpten
Copy link

Warpten commented Apr 21, 2012

Console output:


C:\Program Files\nodejs>npm install jsdom
npm http GET https://registry.npmjs.org/jsdom
npm http 304 https://registry.npmjs.org/jsdom
npm http GET https://registry.npmjs.org/cssom
npm http GET https://registry.npmjs.org/contextify
npm http GET https://registry.npmjs.org/request
npm http 304 https://registry.npmjs.org/cssom
npm http 304 https://registry.npmjs.org/request
npm http 304 https://registry.npmjs.org/contextify
npm http GET https://registry.npmjs.org/bindings
npm http 304 https://registry.npmjs.org/bindings

> contextify@0.1.2 install C:\Program Files\nodejs\node_modules\jsdom\node_modul
es\contextify
> 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',
  'binding.gyp',
  '-IC:\\Program Files\\nodejs\\node_modules\\jsdom\\node_modules\\contextify\\b
uild\\config.gypi',
  '-f',
  'msvs',
  '-G',
  '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\__init__.py", line
 8, in ?
    import gyp.input
  File "C:\Users\perquet\.node-gyp\0.6.15\tools\gyp\pylib\gyp\input.py", line 14
, in ?
    import gyp.common
  File "C:\Users\perquet\.node-gyp\0.6.15\tools\gyp\pylib\gyp\common.py", line 1
08
    @memoize
    ^
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
ib\configure.js:196:18)
    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.

@stefek99
Copy link

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


OSX 10.6.8
node --version
v0.6.15

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)```

@Warpten
Copy link

Warpten commented Apr 23, 2012

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

@eamason9629
Copy link

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

Thanks!

@nbunney
Copy link

nbunney commented May 3, 2012

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

@nbunney
Copy link

nbunney commented May 3, 2012

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

@kamranayub
Copy link

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!

@tmpvar
Copy link
Member

tmpvar commented May 9, 2012

awesome! thank you for looking into this @kamranayub!

@Warpten
Copy link

Warpten commented May 9, 2012

Confirmed, working fix. Thanks a lot :)

@SunboX
Copy link
Author

SunboX commented May 10, 2012

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

@smschauhan
Copy link

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.

@Warpten
Copy link

Warpten commented May 27, 2012

Follow @kamranayub 's tip.

@smschauhan
Copy link

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

@kamranayub
Copy link

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

http://encosia.com/cheerio-faster-windows-friendly-alternative-jsdom

@smschauhan
Copy link

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 :)

@Leonidas-from-XIV
Copy link

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

@eastridge
Copy link

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

@robot1125
Copy link

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?

@olivierphi
Copy link

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.

@JamesEggers1
Copy link

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.

@tokudu
Copy link

tokudu commented Sep 18, 2012

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

@domenic
Copy link
Member

domenic commented Oct 5, 2012

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

@ivankravchenko
Copy link

On MacOS 10.8. Installed fresh Xcode and brew, python. Contextify fails to build.
This fixed for me.
export PATH=/Applications/Xcode.app/Contents/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/:$PATH
sudo ln -s /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/usr/include /usr/include
sudo ln -s /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/usr/lib/* /usr/lib/
npm install contextify

@ghost
Copy link

ghost commented Jan 24, 2013

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.

@domenic
Copy link
Member

domenic commented Jan 24, 2013

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.

@niued
Copy link

niued commented Feb 19, 2013

how to solve this problem?

@domenic
Copy link
Member

domenic commented Feb 19, 2013

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

@tacticalchihuahua
Copy link

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)

@nickgeorge
Copy link

fwiw, I have this problem on ubuntu

@domenic
Copy link
Member

domenic commented Apr 3, 2013

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

@mlilley
Copy link

mlilley commented Apr 5, 2013

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

HTH

@frabcus
Copy link

frabcus commented Apr 8, 2013

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
v0.6.12
# npm -v
1.1.4

@frabcus
Copy link

frabcus commented Apr 8, 2013

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
585c2cd#package.json

@Sirk
Copy link

Sirk commented May 25, 2013

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

"dependencies" : {
    "contextify":"0.1.3",
    "express":"3.1.0",
    "jsdom":"0.5.4"
},

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

npm shrinkwrap

and

npm install

@jsolis
Copy link

jsolis commented Feb 16, 2014

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
Labels
None yet
Projects
None yet
Development

No branches or pull requests