Node.js "Cannot read property 'userAgent' of undefined" on require

Edit4: I'm happy working in this in Linux now, as I got the rest of the kinks with where to place and how to copy the files out of the way for the project. Going to go ahead and accept the answer and close this out.

Edit3: I have a workaround in place for the moment, namely working out of my Debian VM instead of Windows, thanks to Len's comments. However, I am leaving this unanswered for now to see if someone can solve the Windows problem.

I have slowly been working my way through an install of Node.js on my Windows 7 desktop. I say slowly because every step of the way has had issues, from PATH variables not updating, to not knowing I needed python, to npm permissions errors. Anyway, I've worked through a ton of them with Google's help, but this has me completely stumped:

D:\Website\Webscraper>node webscrape.js

node.js:201
        throw e; // process.nextTick error, or 'error' event on first tick
              ^
TypeError: Cannot read property 'userAgent' of undefined
    at D:\Website\Webscraper\node_modules\jquery\lib\node-jquery.js:87:23
    at D:\Website\Webscraper\node_modules\jquery\lib\node-jquery.js:995:2
    at create (D:\Website\Webscraper\node_modules\jquery\lib\node-jquery.js:9416:2)
    at D:\Website\Webscraper\node_modules\jquery\lib\node-jquery.js:9422:18
    at Object.<anonymous> (D:\Website\Webscraper\node_modules\jquery\lib\node-jquery.js:9424:1)
    at Module._compile (module.js:441:26)
    at Object..js (module.js:459:10)
    at Module.load (module.js:348:31)
    at Function._load (module.js:308:12)
    at Module.require (module.js:354:17)

Here's my entire code:

var $ = require('jquery');

After endless errors about missing packages, I have the following installed locally via npm:

  • jquery@1.7.2
  • htmlparser@1.7.6
  • jsdom@0.2.14
  • cssom@0.2.3
  • request@2.9.202
  • xmlhttprequest@1.3.0
  • location@0.0.1
  • navigator@1.0.1

But since the error I am now getting is a pretty generic JS error, and searching for it specifically has netted 0 google hits, I am stumped. All I want to do is run jquery in node.js. This was supposed to require ~3 lines of input. What the heck am I missing?

Edit: Looking into the navigator.userAgent end of things, it looks like the navigator package I downloaded is meant to fix this, but it's not working. I also tried editing node-jquery in the jquery module, overriding the global variable "navigator" with one that sets my own userAgent, and a couple other things, but nothing even changes the error, much less fixes the problem.

Edit2: (fixed for Debian, see comments under Len's answer)

Works for me!

aeka ~/test$ cat webscrape.js 
var $ = require('jquery');
aeka ~/test$ node webscrape.js 
aeka ~/test$ echo $?
0
aeka ~/test$ npm ls
/Users/annelicuss/test
├─┬ jquery@1.7.2 
│ ├── htmlparser@1.7.6 
│ ├─┬ jsdom@0.2.14 
│ │ ├─┬ contextify@0.1.2 
│ │ │ └── bindings@0.3.0 
│ │ ├── cssom@0.2.3 
│ │ └── request@2.9.202 
│ └── xmlhttprequest@1.3.0 
└── navigator@1.0.1 

aeka ~/test$