SitePoint Sponsor

User Tag List

Results 1 to 9 of 9

Hybrid View

  1. #1
    SitePoint Member
    Join Date
    Feb 2013
    Posts
    19
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    C.h 2: Checked out code, getting error

    Hello,

    I wrote the code in the book (basically hand copied) and I am getting this error when running the code:

    Code:
    D:\JumpStartNodeJs\nockmarket\node_modules\jquery\lib\node-jquery.js:10
        window.XMLHttpRequest.prototype.withCredentials = false;
                             ^
    TypeError: Cannot read property 'prototype' of undefined
        at create (D:\JumpStartNodeJs\nockmarket\node_modules\jquery\lib\node-jquery.js:10:26)
        at D:\JumpStartNodeJs\nockmarket\node_modules\jquery\lib\node-jquery.js:9435:18
        at Object.<anonymous> (D:\JumpStartNodeJs\nockmarket\node_modules\jquery\lib\node-jquery.js:9437:2)
        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> (D:\JumpStartNodeJs\nockmarket\lib\exchange.js:3:9)
    I then downloaded the code from the git hub repo and I am getting the same error.

    Any thoughts?

  2. #2
    SitePoint Member
    Join Date
    Jul 2013
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Ch. 2, jQuery node_module failing to "trick" jQuery into thinking CORS is supported?

    Thank you very much for submitting this error.
    I am bumping into exactly the same issue.
    And yes, this happened on code downloaded from repo.

    Looking at the line reported in the error:
    node-jquery.js
    Code JavaScript:
    function create(window) {
     
      if(window == null ) {
        window = require('jsdom').jsdom().createWindow();
        // assume window is a jsdom instance...
        // jsdom includes an incomplete version of XMLHttpRequest
        window.XMLHttpRequest = require("xmlhttprequest").XMLHttpRequest;
        // trick jQuery into thinking CORS is supported (should be in node-XMLHttpRequest)
        window.XMLHttpRequest.prototype.withCredentials = false;

    From looking further into the node_modules it appears 'XMLHttpRequest.js' is down in there; is there supposed to be a 'node-XMLHttpRequest' ?

    I'm confused. Wish it would be just working. Hope to be able to move on from Ch. 02 but stuck at moment.

    Many thanks,
    William Reilly

    administrators-MacBook-Air-2:chapter02 william.reilly$ node nockmarket

    /Users/william.reilly/dev/Node/JumpStart-Node/wr_dev/chapter02/node_modules/jquery/lib/node-jquery.js:10
    window.XMLHttpRequest.prototype.withCredentials = false;
    ^
    TypeError: Cannot read property 'prototype' of undefined
    at create (/Users/william.reilly/dev/Node/JumpStart-Node/wr_dev/chapter02/node_modules/jquery/lib/node-jquery.js:10:26)
    at /Users/william.reilly/dev/Node/JumpStart-Node/wr_dev/chapter02/node_modules/jquery/lib/node-jquery.js:9435:18
    at Object.<anonymous> (/Users/william.reilly/dev/Node/JumpStart-Node/wr_dev/chapter02/node_modules/jquery/lib/node-jquery.js:9437:2)
    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> (/Users/william.reilly/dev/Node/JumpStart-Node/wr_dev/chapter02/lib/exchange.js:7:9)
    administrators-MacBook-Air-2:chapter02 william.reilly$

  3. #3
    SitePoint Member
    Join Date
    Feb 2013
    Posts
    19
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by wreilly View Post
    Thank you very much for submitting this error.
    I am bumping into exactly the same issue.
    And yes, this happened on code downloaded from repo.

    Looking at the line reported in the error:
    node-jquery.js
    Code JavaScript:
    function create(window) {
     
      if(window == null ) {
        window = require('jsdom').jsdom().createWindow();
        // assume window is a jsdom instance...
        // jsdom includes an incomplete version of XMLHttpRequest
        window.XMLHttpRequest = require("xmlhttprequest").XMLHttpRequest;
        // trick jQuery into thinking CORS is supported (should be in node-XMLHttpRequest)
        window.XMLHttpRequest.prototype.withCredentials = false;

    From looking further into the node_modules it appears 'XMLHttpRequest.js' is down in there; is there supposed to be a 'node-XMLHttpRequest' ?

    I'm confused. Wish it would be just working. Hope to be able to move on from Ch. 02 but stuck at moment.

    Many thanks,
    William Reilly

    administrators-MacBook-Air-2:chapter02 william.reilly$ node nockmarket

    /Users/william.reilly/dev/Node/JumpStart-Node/wr_dev/chapter02/node_modules/jquery/lib/node-jquery.js:10
    window.XMLHttpRequest.prototype.withCredentials = false;
    ^
    TypeError: Cannot read property 'prototype' of undefined
    at create (/Users/william.reilly/dev/Node/JumpStart-Node/wr_dev/chapter02/node_modules/jquery/lib/node-jquery.js:10:26)
    at /Users/william.reilly/dev/Node/JumpStart-Node/wr_dev/chapter02/node_modules/jquery/lib/node-jquery.js:9435:18
    at Object.<anonymous> (/Users/william.reilly/dev/Node/JumpStart-Node/wr_dev/chapter02/node_modules/jquery/lib/node-jquery.js:9437:2)
    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> (/Users/william.reilly/dev/Node/JumpStart-Node/wr_dev/chapter02/lib/exchange.js:7:9)
    administrators-MacBook-Air-2:chapter02 william.reilly$
    Did you manage to figure this out?

  4. #4
    SitePoint Member
    Join Date
    Feb 2013
    Posts
    19
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Also, did you have difficulty pulling down the required imports? I had difficulty installing jquery with npm.

  5. #5
    SitePoint Member
    Join Date
    Jul 2013
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Book author recommends pulling jQuery, has substituted his own npm module 'clone'

    O.K., Googling the error message wording (ever a good idea), led to the page that led to the answer:

    http://www.sitepoint.com/forums/show...tibility-issue

    (This is also under the same forum, but that title didn't lead me to look at it.)

    The book author points to:
    https://github.com/coolaj86/node-jquery/issues/35
    https://gist.github.com/deltanovember/4167847
    https://gist.github.com/4167853

    As noted by someone there, you need to run 'npm install clone'

    This is the book author's alternative to using jQuery just to get clone functionality. He's recommended removing jQuery ('npm rm jquery') to avoid the larger issue that jQuery is having with this xmlhttprequest thing. Something to do with failed dependencies (I saw on my install as well: 'gyp' (?) didn't install right, and 'jsdom' needs 'contextify' (?) which also didn't install right (there's lots of pages out there with people having trouble with that). Best walk away from all this if you have an alternative, as we now do with the 'clone' module from the book author).

    Once clone installed, then 'make test' did yield finally what the book on page 38-39 shows:

    administrators-MacBook-Air-2:chapter02 william.reilly$ make test

    ...

    ✔ 3 tests complete (9ms)

    administrators-MacBook-Air-2:chapter02 william.reilly$


    Good grief, lot of pain to get there.

    Best,
    William R.

  6. #6
    SitePoint Member
    Join Date
    Jul 2013
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    One further note: "typo" (missing line) in Book Page 22:

    chapter02/test/exchange.test.js

    var assert = require('assert')
    , should = require('should')
    , exchange = require('../lib/exchange'); // BOOK page 22 is MISSING this line.

  7. #7
    SitePoint Member
    Join Date
    Feb 2013
    Posts
    19
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by wreilly View Post
    O.K., Googling the error message wording (ever a good idea), led to the page that led to the answer:

    http://www.sitepoint.com/forums/show...tibility-issue

    (This is also under the same forum, but that title didn't lead me to look at it.)

    The book author points to:
    https://github.com/coolaj86/node-jquery/issues/35
    https://gist.github.com/deltanovember/4167847
    https://gist.github.com/4167853

    As noted by someone there, you need to run 'npm install clone'

    This is the book author's alternative to using jQuery just to get clone functionality. He's recommended removing jQuery ('npm rm jquery') to avoid the larger issue that jQuery is having with this xmlhttprequest thing. Something to do with failed dependencies (I saw on my install as well: 'gyp' (?) didn't install right, and 'jsdom' needs 'contextify' (?) which also didn't install right (there's lots of pages out there with people having trouble with that). Best walk away from all this if you have an alternative, as we now do with the 'clone' module from the book author).

    Once clone installed, then 'make test' did yield finally what the book on page 38-39 shows:

    administrators-MacBook-Air-2:chapter02 william.reilly$ make test

    ...

    ✔ 3 tests complete (9ms)

    administrators-MacBook-Air-2:chapter02 william.reilly$


    Good grief, lot of pain to get there.

    Best,
    William R.
    I'm seeing this when I
    Code:
    make test
    :

    Code:
    ? 3 tests complete (30 ms)
    Any idea what the '?' means?

  8. #8
    SitePoint Member
    Join Date
    Feb 2013
    Posts
    19
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Awesome, thanks!


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
  •