canirequire

canirequireCommonJS › request-promise

Is request-promise ESM-only? Can you require() it?

The simplified HTTP request client 'request' with Promise support. Powered by Bluebird.

Latest version 4.2.6, published Jul 22, 2020. JSON

CommonJS CommonJS — require() works on every Node.js version

request-promise ships CommonJS only. require("request-promise") works everywhere. import "request-promise" also works because Node.js and Bun can import CommonJS from ES modules, but only the default export is guaranteed; named imports depend on Node's static analysis of the module.

Latest
4.2.6 (Jul 22, 2020)
Module format
CommonJS
Last CommonJS version
4.2.6
TypeScript types
@types/request-promise
Node engines
>=0.10.0
Weekly downloads
841K
License
ISC

Deprecated: request-promise has been deprecated because it extends the now deprecated request package, see https://github.com/request/request/issues/3142

Does request-promise@4.2.6 actually load? Runtime test results

Runtime probe pending for this version. The values below are what package.json declares; they are refreshed once the probe runs.

Runtimerequire("request-promise")import "request-promise"
Node.js 18✓ expected✓ expected
Node.js 20✓ expected✓ expected
Node.js 22✓ expected✓ expected
Node.js 24✓ expected✓ expected
Node.js 26✓ expected✓ expected
Bun 1.4pendingpending

Install failed in our sandbox: error: ConnectionRefused downloading package manifest request-promise The rows above show what package.json declares.

How to import request-promise

ES modules (import)

import requestPromise from "request-promise";

Named imports from a CommonJS package only work when Node.js can statically detect them. If a named import fails, use the default import and destructure.

CommonJS (require)

const requestPromise = require("request-promise");

Module format by version

Derived from the type, main and exports fields of every stable release on npm (42 versions; the newest 42 shown).

VersionsFormatFirst published
0.0.1 – 4.2.6CommonJSOct 4, 2013

Frequently asked

Is request-promise ESM-only?

request-promise@4.2.6 is a CommonJS package. request-promise ships CommonJS only. require("request-promise") works everywhere. import "request-promise" also works because Node.js and Bun can import CommonJS from ES modules, but only the default export is guaranteed; named imports depend on Node's static analysis of the module.

Can I import request-promise with ES module syntax?

Yes. import requestPromise from "request-promise" works in Node.js and Bun because they support importing CommonJS modules. Named imports work only when Node.js can statically detect the exports.

Does request-promise ship TypeScript types?

Not bundled. Install the community types with "npm install -D @types/request-promise".

Links

Other commonjs packages

Similar popularity