Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3500282
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T12:42:53+00:00 2026-05-18T12:42:53+00:00

I am trying to run simple code from examples: require.paths.unshift(‘/etc/npm’); // path to modules

  • 0

I am trying to run simple code from examples:

require.paths.unshift('/etc/npm'); // path to modules
var httpAgent = require('http-agent'),
    jsdom = require('jsdom'),
    sys = require('sys');

var agent = httpAgent.create('www.twitter.com', ['', 'about']);

agent.addListener('next', function (e, agent) {
  var body = agent.body;
  var window = jsdom.jsdom(body, {},{}).createWindow();
  jsdom.jQueryify(window, 'http://code.jquery.com/jquery-1.4.2.js', function (window, jquery) {
    agent.next();
  });
});

agent.addListener('stop', function (agent) {
  sys.puts('the agent has stopped');
});

agent.start();

But it returns a lot of errors on this line:

var window = jsdom.jsdom(body, {},{}).createWindow();

Erros:

kir@nas:~/node$ node test.js

/usr/local/lib/node/.npm/jsdom/0.1.21/package/lib/jsdom/browser/index.js:197
  if (!dom.HTMLDocument.write) {
                       ^
TypeError: Cannot read property 'write' of undefined
    at Object.browserAugmentation (/usr/local/lib/node/.npm/jsdom/0.1.21/package/lib/jsdom/browser/index.js:197:24)
    at Object.jsdom (/usr/local/lib/node/.npm/jsdom/0.1.21/package/lib/jsdom.js:15:25)
    at EventEmitter.<anonymous> (/home/kir/node/test.js:12:22)
    at EventEmitter.emit (events:27:15)
    at Object.emit (/usr/local/lib/node/.npm/http-agent/0.1.0/package/lib/http-agent.js:180:41)
    at /usr/local/lib/node/.npm/http-agent/0.1.0/package/lib/http-agent.js:145:14
    at IncomingMessage.<anonymous> (/usr/local/lib/node/.npm/request/0.10.0/package/lib/main.js:89:7)
    at IncomingMessage.emit (events:41:20)
    at HTTPParser.onMessageComplete (http:107:23)
    at Client.onData [as ondata] (http:848:27)

I have Ubuntu 10.10 with stable node.js 0.2.5. WTF?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T12:42:53+00:00Added an answer on May 18, 2026 at 12:42 pm

    Normal for jsom, it’s work in progress, the DOM API is gigantic and re-implementing all the Browser quirks takes a lot of time.

    But first of all your call jsdom.jsdom(body, {},{}).createWindow(); is wrong, second parameter should be a fully configure DOM object, if you don’t provide one just pass null to make it fall back to a default one.

    But after that it’s turtles all the way down.

    Twitter for example does this window.top.location, turns out that jsdom does not define window.top and BOOM!

    Fixing that… yeah, turtles. The errors don’t stop, if you’re interested in fixing it all the way down, open <npm folder>/jsdom/0.1.21/package/lib/jsdom/level2/languages/javascript.js there you can log the code and do fixes to the window object till it works.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.