{"id":14380,"library":"xmlhttprequest","title":"Node.js XMLHttpRequest (driverdan)","description":"The `xmlhttprequest` package provides a CommonJS-compatible implementation of the browser's XMLHttpRequest (XHR) object for Node.js environments. Its primary goal is to enable developers to reuse JavaScript code designed for browsers, particularly older libraries, within a Node.js context by emulating the standard XHR API. The latest version, 1.8.0, was published over a decade ago (October 2015), and the package has since been largely unmaintained. It conforms to the XMLHttpRequest Level 1 specification, lacking many features found in modern XMLHttpRequest Level 2 or the Fetch API. Due to its abandoned status and the existence of more actively maintained alternatives like `xhr2` or `w3c-xmlhttprequest`, new projects should generally avoid this package. Its release cadence was irregular, tied to core code changes or W3C spec conformity, but no significant updates have occurred in years. Key differentiators include its simple, direct emulation for older Node.js versions (0.4.0+) and minimal dependencies.","status":"abandoned","version":"1.8.0","language":"javascript","source_language":"en","source_url":"git://github.com/driverdan/node-XMLHttpRequest","tags":["javascript","xhr","ajax"],"install":[{"cmd":"npm install xmlhttprequest","lang":"bash","label":"npm"},{"cmd":"yarn add xmlhttprequest","lang":"bash","label":"yarn"},{"cmd":"pnpm add xmlhttprequest","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"This package is CommonJS-only and does not support ES modules. The XMLHttpRequest constructor is exported as a property of the main module export.","wrong":"import { XMLHttpRequest } from 'xmlhttprequest';","symbol":"XMLHttpRequest","correct":"const XMLHttpRequest = require('xmlhttprequest').XMLHttpRequest;"}],"quickstart":{"code":"const XMLHttpRequest = require('xmlhttprequest').XMLHttpRequest;\n\nconst xhr = new XMLHttpRequest();\nxhr.open('GET', 'https://example.com/api/data', true); // `true` for asynchronous request\nxhr.onload = function () {\n  if (xhr.status >= 200 && xhr.status < 300) {\n    console.log('Response:', xhr.responseText);\n  } else {\n    console.error('Request failed with status:', xhr.status, xhr.statusText);\n  }\n};\nxhr.onerror = function () {\n  console.error('Network error or CORS issue occurred.');\n};\nxhr.send();\n\nconsole.log('XMLHttpRequest instance created and request sent.');","lang":"javascript","description":"Demonstrates how to import the XMLHttpRequest constructor using CommonJS and perform a basic asynchronous GET request to an example URL."},"warnings":[{"fix":"Migrate to `xhr2` (`npm i xhr2`) or `w3c-xmlhttprequest` (`npm i w3c-xmlhttprequest`) for a more up-to-date and maintained XHR implementation, or use native Node.js HTTP clients.","message":"This package is unmaintained and considered abandoned. It has not received updates since 2015 and does not implement modern XMLHttpRequest Level 2 features or security fixes. Consider using alternatives like `xhr2` or Node.js's native `http`/`https` modules, or the `undici` package for robust HTTP client functionality.","severity":"breaking","affected_versions":">=1.8.0"},{"fix":"Be aware of missing features. For modern web APIs, this library is insufficient. Use alternative XHR polyfills or Node.js native `http`/`https` for full control.","message":"The package only conforms to XMLHttpRequest Level 1. Many features common in modern browsers and expected in current web development, such as `FormData`, `Blob`, `file://` URIs, specific progress events (e.g., upload), `responseType='json'`, and proper cookie persistence, are not implemented or behave unexpectedly.","severity":"gotcha","affected_versions":"<=1.8.0"},{"fix":"Always prefer asynchronous requests by setting the third argument of `open()` to `true` (or omitting it, as `true` is the default). Avoid synchronous XHR in Node.js entirely.","message":"Synchronous XMLHttpRequest requests (where the third argument to `open()` is `false`) are known to freeze the Node.js event loop while waiting for a response. They also have reported issues with not setting headers properly.","severity":"gotcha","affected_versions":"<=1.8.0"},{"fix":"Always use the exact lowercase string `\"xmlhttprequest\"` in your `require()` calls: `require(\"xmlhttprequest\")`.","message":"Due to Node.js's case-sensitive module resolution on Linux and other Unix-like systems, using an incorrect casing in the `require()` path (e.g., `require(\"XMLHttpRequest\")`) will result in a 'Cannot find module' error.","severity":"gotcha","affected_versions":"<=1.8.0"}],"env_vars":null,"search_vec":"'0.4.0':150 '1':76 '1.8.0':53 '2':86 '2015':61 'abandon':94 'activ':101 'ago':59 'ajax':156 'altern':103 'api':49,90 'avoid':114 'browser':15,36 'cadenc':119 'chang':126 'code':33,125 'commonj':10 'commonjs-compat':9 'compat':11 'conform':71,130 'context':43 'core':124 'decad':58 'depend':153 'design':34 'develop':29 'differenti':140 'direct':144 'driverdan':3 'due':91 'emul':45,145 'enabl':28 'environ':22 'exist':98 'featur':80 'fetch':89 'found':81 'general':113 'goal':25 'implement':12 'includ':141 'irregular':121 'javascript':32,154 'key':139 'lack':78 'larg':68 'latest':51 'level':75,85 'librari':39 'like':104 'maintain':102 'mani':79 'minim':152 'modern':83 'new':110 'node.js':1,21,42,148 'object':19 'occur':136 'octob':60 'older':38,147 'packag':6,64,116 'particular':37 'primari':24 'project':111 'provid':7 'publish':55 'releas':118 'reus':31 'signific':133 'simpl':143 'sinc':66 'spec':129 'specif':77 'standard':47 'status':95 'tie':122 'unmaintain':69 'updat':134 'version':52,149 'w3c':108,128 'w3c-xmlhttprequest':107 'within':40 'xhr':18,48,155 'xhr2':105 'xmlhttprequest':2,5,17,74,84,109 'year':138","created_at":"2026-04-20T01:59:24.270163+00:00","updated_at":"2026-04-20T01:59:24.270163+00:00","problems":[{"fix":"Ensure the package name in `require()` is all lowercase: `require('xmlhttprequest')`.","cause":"The `require()` path used an incorrect casing for the package name. Node.js module resolution is case-sensitive on many operating systems.","error":"Error: Cannot find module 'XMLHttpRequest'"},{"fix":"Change the `open()` method call to be asynchronous: `xhr.open('GET', url, true);` (or omit the third argument as `true` is default).","cause":"A synchronous XMLHttpRequest was used, which blocks the Node.js event loop until the request completes.","error":"Node.js process freezes or becomes unresponsive during an HTTP request."}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/driverdan/node-XMLHttpRequest","docs":null,"changelog":null,"pypi":null,"npm":"https://www.npmjs.com/package/xmlhttprequest","openapi_spec":null,"status_page":null,"smithery":null,"categories":["http-networking"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-17","next_check":"2026-07-18","install_tag":null}}