SitePoint Sponsor

User Tag List

Results 1 to 14 of 14
  1. #1
    SitePoint Member
    Join Date
    Jun 2010
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Node.js - nodeunit or Make and node-jquery compatibility issue

    When I try to run a unit test I get following error:

    C:\users\thomas\chap02\node_modules\jquery\lib\node-jquery.js:10
    window.XMLHttpRequest.prototype.withCredentials = false;
    ^
    TypeError: Cannot read property 'prototype' of undefined
    at create (C:\users\thomas\chap02\node_modules\jquery\lib\node-jquery.js:10:26)
    at C:\users\thomas\chap02\node_modules\jquery\lib\node-jquery.js:9435:18
    at Object.<anonymous>
    (C:\users\thomas\chap02\node_modules\jquery\lib\node-jquery.js:9437:2)
    at Module._compile (module.js:449:26)
    at Object.Module._extensions..js (module.js:467:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Module.require (module.js:362:17)
    at require (module.js:378:17)
    at Object.<anonymous> (C:\users\thomas\chap02\lib\exchange.js:3:9)
    at Module._compile (module.js:449:26)
    at Object.Module._extensions..js (module.js:467:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Module.require (module.js:362:17)
    at require (module.js:378:17)
    at Object.<anonymous> (C:\users\thomas\chap02\test\exchange.test.js:7:14)
    at Module._compile (module.js:449:26)
    at Object.Module._extensions..js (module.js:467:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Module.require (module.js:362:17)
    at require (module.js:378:17)
    at C:\users\thomas\chap02\node_modules\mocha\bin\_mocha:313:27
    at Array.forEach (native)
    at load (C:\users\thomas\chap02\node_modules\mocha\bin\_mocha:310:9)
    at Object.<anonymous>
    (C:\users\thomas\chap02\node_modules\mocha\bin\_mocha:301:1)
    at Module._compile (module.js:449:26)
    at Object.Module._extensions..js (module.js:467:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Module.runMain (module.js:492:10)
    at process.startup.processNextTick.process._tickCallback (node.js:244:9)
    Makefile:2: recipe for target `test' failed
    make: *** [test] Error 1

    I am developing on windows 7 with Cygwin so I have a shell in some flavor.

    Do you know a way to keep modules code out of the test scope - no need to test module code (already tested)?

    Or do you know how to make this work?

    Thanks ; )

  2. #2
    Under Construction silver trophybronze trophy AussieJohn's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    776
    Mentioned
    11 Post(s)
    Tagged
    0 Thread(s)
    I've seen some other folks come across this issue as well... I didn't seem to have it until I downgraded to Node 0.8.14 yesterday, in Node 0.9.2 it wasn't doing this to me.

    Try reinstalling the jquery module and see how you go.

    Run this in the chapter's directory:
    Code:
    npm install jquery
    var details = {
    . . web: "afterlight.com.au",
    . . photos: "jvdl.id.au",
    . . psa: "usethelatestversion.com"
    }

  3. #3
    SitePoint Member
    Join Date
    Jun 2010
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Decided to install a visualbox on my windows machine and installed ubunto. Than I had the issue again when i installed jquery I noticed i needed make g++ - C++ build essential. I installed it and reinstalled jquery and then the make test also worked. However i also installed nvm and use node0.9.2. So now make test works - and all tests evalutes to green ; ) Thanks saved me a lot time.

  4. #4
    SitePoint Author
    Join Date
    Nov 2012
    Posts
    48
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    thomasoriis, see my answer #10 here:

    http://www.sitepoint.com/forums/show...ain)&p=5227649

  5. #5
    SitePoint Member
    Join Date
    Jun 2010
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks Don - and thank you for your book. Yes that would solve the problem - however I am also developing an other application that needs more of jquery. But the link can help others I hope. Btw maybe you should point to sitepoint forums from the books site. I had to write to books@sitepoint.com and was directed to this forum. I would have saved me a lot of pain and efford : )

  6. #6
    SitePoint Member
    Join Date
    Dec 2010
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Don, could you repost that link above? It does not appear to be working

    Stuck in chapter 2 at the moment.

  7. #7
    SitePoint Author
    Join Date
    Nov 2012
    Posts
    48
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    garyklinecc, I can't locate the post even after searching my entire history. I will check with the admins to see what has happened to it. In the meantime if you post what issues you're having I'm happy to look at it afresh.

  8. #8
    SitePoint Member
    Join Date
    Dec 2010
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Don, I'm having the same error message as thomasoriis reported. When I use npm install jquery, it runs into errors like so:

    C:\Users\GaryK\node\chapter02>npm install jquery
    npm WARN package.json nockmarket@0.0.1 No README.md file found!
    npm http GET https://registry.npmjs.org/jquery/1.7.3
    npm http 304 https://registry.npmjs.org/jquery/1.7.3
    npm http GET https://registry.npmjs.org/navigator
    npm http GET https://registry.npmjs.org/htmlparser/1.7.6
    npm http GET https://registry.npmjs.org/location/0.0.1
    npm http GET https://registry.npmjs.org/jsdom
    npm http GET https://registry.npmjs.org/xmlhttprequest
    npm http 304 https://registry.npmjs.org/navigator
    npm http 304 https://registry.npmjs.org/htmlparser/1.7.6
    npm http 304 https://registry.npmjs.org/location/0.0.1
    npm http 304 https://registry.npmjs.org/jsdom
    npm http 304 https://registry.npmjs.org/xmlhttprequest
    npm http GET https://registry.npmjs.org/cssom
    npm http GET https://registry.npmjs.org/contextify
    npm http GET https://registry.npmjs.org/cssstyle
    npm http GET https://registry.npmjs.org/request
    npm http 304 https://registry.npmjs.org/cssom
    npm WARN package.json cssom@0.2.5 No README.md file found!
    npm http 304 https://registry.npmjs.org/contextify
    npm http 304 https://registry.npmjs.org/cssstyle
    npm http 304 https://registry.npmjs.org/request
    npm http GET https://registry.npmjs.org/bindings
    npm http 304 https://registry.npmjs.org/bindings

    > contextify@0.1.3 install C:\Users\GaryK\node\chapter02\node_modules\jquery\nod
    e_modules\jsdom\node_modules\contextify
    > node-gyp rebuild


    C:\Users\GaryK\node\chapter02\node_modules\jquery\node_modules\jsdom\node_module
    s\contextify>node "C:\Program Files (x86)\nodejs\node_modules\npm\bin\node-gyp-b
    in\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild
    gyp ERR! rebuild error Error: Can't find Python executable "python", you can set
    the PYTHON env variable.
    gyp ERR! rebuild error at failNoPython (C:\Program Files (x86)\nodejs\node_m
    odules\npm\node_modules\node-gyp\lib\configure.js:85:14)
    gyp ERR! rebuild error at Object.oncomplete (C:\Program Files (x86)\nodejs\n
    ode_modules\npm\node_modules\node-gyp\lib\configure.js:59:11)
    gyp ERR! not ok
    npm WARN optional dep failed, continuing contextify@0.1.3
    jquery@1.7.3 node_modules\jquery
    ├── navigator@1.0.1
    ├── location@0.0.1
    ├── xmlhttprequest@1.4.2
    ├── htmlparser@1.7.6
    └── jsdom@0.2.19 (cssom@0.2.5, request@2.12.0, cssstyle@0.2.3)

    Between these errors (Python is required?), and the use of Mocha to do test-driven development (requiring "make" to be available), I'm wasting my time using Windows as a node.js development environment. Unfortunately, its the only platform I currently have.

    I'm debating whether to continue forward with the book in a Windows environment (and simply ignore/work around the code that fails (eg Mocha and jQuery), or just wait until I repurpose an older machine with Linux. Apparently the book's code was written on a Linux or Mac.

    I like how the book explains each section of code, and I am excited to start using node.js for a particular project of mine. I really do want to finish the book, and will probably just work around the features that give me difficulties.

  9. #9
    SitePoint Member
    Join Date
    Nov 2012
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi garyklinecc and Don,

    I'm experiencing very similar errors, and I'm working on a Mac, OSX 10.8.

    I'm generating errors similar to thomasoriis and garyklinecc, errors when running make test in chapter 02, and then errors when reinstalling jquery with npm install jquery.

    I've tried to reinstall jquery via (npm install jquery), and I've update my node.js version to 8.15, but no change.

    I did all my testing with the book's example files to ensure that it wan't an error on my part.

    The book is fantastic, and I'd love to be able to continue working through the rest of it. If there's any extra information I can provide to help find a solution, please let me know.

    Thanks for any advice.

    Regards,
    Brent

  10. #10
    SitePoint Author
    Join Date
    Nov 2012
    Posts
    48
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    The problem is related to the following bug in node-jquery:

    https://github.com/coolaj86/node-jquery/issues/35

    The work around is to remove jQuery. It was mainly there as an illustration of what's possible it's not an essential part of the project. The cloning function can be replaced as follows:

    https://gist.github.com/4167847

    This will also require a new package.json:

    https://gist.github.com/4167853

    Please let me know if there are still further issues

  11. #11
    SitePoint Member
    Join Date
    Dec 2010
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Don, thank you for posting the modified code.

    I ended up coding a cloneExchangeData() function, which was actually a good opportunity to learn more about Javascript. Hopefully Brent or someone can post after using the modified code.

    Onward and upward!

  12. #12
    SitePoint Member
    Join Date
    Nov 2012
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Don, it's fantastic that you're such an active member our community. Thank you for posting the workaround.

  13. #13
    SitePoint Member
    Join Date
    Jan 2009
    Location
    Australia
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Thanks - worked like a charm

    Quote Originally Posted by Don Nguyen View Post
    The problem is related to the following bug in node-jquery:

    https://github.com/coolaj86/node-jquery/issues/35

    The work around is to remove jQuery. It was mainly there as an illustration of what's possible it's not an essential part of the project. The cloning function can be replaced as follows:

    https://gist.github.com/4167847

    This will also require a new package.json:

    https://gist.github.com/4167853

    Please let me know if there are still further issues

  14. #14
    SitePoint Member
    Join Date
    Mar 2013
    Location
    Galway, Ireland
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Don Nguyen View Post
    The problem is related to the following bug in node-jquery:

    https://github.com/coolaj86/node-jquery/issues/35

    The work around is to remove jQuery. It was mainly there as an illustration of what's possible it's not an essential part of the project. The cloning function can be replaced as follows:

    https://gist.github.com/4167847

    This will also require a new package.json:

    https://gist.github.com/4167853

    Please let me know if there are still further issues
    cheers for the workaround.

    also needs:
    npm install clone


Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •