dianping/cat · error · Error

jQuery requires a window with a document

Error message

jQuery requires a window with a document

What it means

Error "jQuery requires a window with a document" thrown in dianping/cat.

Source

Thrown at cat-home/src/main/webapp/assets/js/uncompressed/jquery1x.js:29

 *
 * Date: 2014-05-01T17:42Z
 */

(function( global, factory ) {

	if ( typeof module === "object" && typeof module.exports === "object" ) {
		// For CommonJS and CommonJS-like environments where a proper window is present,
		// execute the factory and get jQuery
		// For environments that do not inherently posses a window with a document
		// (such as Node.js), expose a jQuery-making factory as module.exports
		// This accentuates the need for the creation of a real window
		// e.g. var jQuery = require("jquery")(window);
		// See ticket #14549 for more info
		module.exports = global.document ?
			factory( global, true ) :
			function( w ) {
				if ( !w.document ) {
					throw new Error( "jQuery requires a window with a document" );
				}
				return factory( w );
			};
	} else {
		factory( global );
	}

// Pass this if window is not defined yet
}(typeof window !== "undefined" ? window : this, function( window, noGlobal ) {

// Can't do this because several apps including ASP.NET trace
// the stack via arguments.caller.callee and Firefox dies if
// you try to trace through "use strict" call chains. (#13335)
// Support: Firefox 18+
//

var deletedIds = [];

View on GitHub (pinned to e815e74d4c)

Solutions

  1. Load jQuery in a browser environment where window and document exist.
  2. When using jQuery in Node.js, create a DOM with jsdom and pass its window to the jQuery factory.

When it happens

Trigger: Triggered when jQuery 1.x is loaded in an environment without a DOM, such as server-side Node.js without a window/document global (e.g. during SSR or in a Web Worker).

Common situations: See trigger scenarios.


AI-assisted analysis of dianping/cat@e815e74d4c (2026-08-14). Data as JSON: /api/errors/a95b235ba2695d64. Report an issue: GitHub.