有ExpressJS错误的Node.js:无法读取未定义的属性“原型”

运行node.js v0.10.2和express v3.1.1(最新在这个时候)并得到这个错误:

/root/dmr-addresses/node_modules/jquery/lib/node-jquery.js:10 window.XMLHttpRequest.prototype.withCredentials = false; ^ TypeError: Cannot read property 'prototype' of undefined at create (/root/dmr-addresses/node_modules/jquery/lib/node-jquery.js:10:26) at /root/dmr-addresses/node_modules/jquery/lib/node-jquery.js:9503:18 at Object.<anonymous> (/root/dmr-addresses/node_modules/jquery/lib/node-jquery.js:9505: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> (/root/dmr-addresses/address/log.js:1:71) 

log.js的第1行是:

 var $ = require('jquery'); 

我试着运行npm install jquery但它没有解决问题。

检查这个:

同样的错误在这里…我不知道我在做什么,但我改变了节点 – jquery.js第四 – 第五行 ,它开始工作:)

旧:

 if(window == null ) { window = require('jsdom').jsdom().createWindow(); 

新:

 if(!window || !window.document) { window = require('jsdom').createWindow(); window.document = require('jsdom').jsdom(); 

在Node服务器代码中实际上没有原型对象,它们都存储在更好的__ proto __对象中,并且应该使用Object.create / defineProperty 。

你到底在做什么? 运行一个Ajax查询与节点? 如果是这样,你应该使用节点http.request

一个例子可能是:

 require('request').post({ "uri" : "http://example.com/", "headers" : { 'content-type': 'application/json' }, "body" : "hello=world" }, function(e,r,b){ // e = errors, r = response and b = returned body console.log(b,r.statusCode)); }); 

看起来像这是jsdom模块node-jquery依赖的一个问题。 看来这是一个已知的问题,它已经被修复了,但是还没有被发布到npm。

检查出来: https : //github.com/coolaj86/node-jquery/issues/52