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.
npm install xmlhttprequestVerified import paths — ran on the pinned version, not inferred.
Demonstrates how to import the XMLHttpRequest constructor using CommonJS and perform a basic asynchronous GET request to an example URL.
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.
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.
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.
Always use the exact lowercase string `"xmlhttprequest"` in your `require()` calls: `require("xmlhttprequest")`.Ensure the package name in `require()` is all lowercase: `require('xmlhttprequest')`.Change the `open()` method call to be asynchronous: `xhr.open('GET', url, true);` (or omit the third argument as `true` is default).No dependency data recorded yet.