简体   繁体   English

Node.JS和Jquery - typeError createWindow不是函数

[英]Node.JS and Jquery - typeError createWindow is not a function

I am trying to play around with node.js and send a xmlhttp request to a server from my server.js file using node.js server object. 我正在尝试使用node.js并使用node.js服务器对象从我的server.js文件向服务器发送xmlhttp请求。

I have defined the following at the beginning of my .js file: 我在.js文件的开头定义了以下内容:

var http = require('http');
var jsdom = require('jsdom');
var $ = require('jquery');

When I try to run the .js file using the nodejs console I get the following error: 当我尝试使用nodejs控制台运行.js文件时,我收到以下错误:

require(...).jsdom(...).createWindow is not a function require(...)。jsdom(...)。createWindow不是一个函数

Is there something obvious I am missing? 有什么明显的东西我不见了吗?

I have looked around for answers but got no further. 我四处寻找答案,但没有进一步。

Thanks for the response. 谢谢你的回复。

It seemed that this was a known bug in an older version of jquery. 似乎这是旧版jquery中的已知错误。 Reinstalling the newest version of Jquery in node.js solved this issue. 在node.js中重新安装最新版本的Jquery解决了这个问题。

Go to your package.json file and see under the dependencies , which version of jQuery you are using. 转到你的package.json文件,看看dependencies ,你正在使用哪个版本的jQuery。 Chances are you are using 1.7.4 你有机会使用1.7.4

I faced the same issue with this older version. 这个旧版本我遇到了同样的问题。 Move to Jquery 3.2.1 to resolve it. 转到Jquery 3.2.1解决它。

When your do, 什么时候做的,

npm install jQuery

It installs the old version. 它安装旧版本。

On doing 在做

npm install jquery

It installs the newer version. 它安装了较新的版本。

The difference is only the uppercase Q. 区别仅在于大写Q.

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM