canirequire › CommonJS › 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. Markdown · JSON
CommonJS CommonJS — require() works on every Node.js version we test
request-promise ships CommonJS only. require("request-promise") should work on every Node.js version the package supports (>=0.10.0); the runtime probe has not run for this version. 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.
What to do
- require("request-promise") should work on every Node.js version the package supports (>=0.10.0); the runtime probe has not run for this version.
- From ES modules use the default import: import requestPromise from "request-promise"; then destructure. Named imports only work when Node.js can statically detect the exports.
- TypeScript: npm install -D @types/request-promise
- This package is deprecated: request-promise has been deprecated because it extends the now deprecated request package, see https://github.com/request/request/issues/3142
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.
| Runtime | require("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.4.0 | pending | pending |
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, corrected where a runtime test of that version contradicted them (42 versions; the newest 42 shown).
| Versions | Format | First published |
|---|---|---|
| 0.0.1 – 4.2.6 | CommonJS | Oct 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") should work on every Node.js version the package supports (>=0.10.0); the runtime probe has not run for this version. 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
- debug 4.4.3CommonJS
- semver 7.8.5CommonJS
- ms 2.1.3CommonJS
- picomatch 4.0.7CommonJS
- ajv 8.20.0CommonJS
- source-map 0.8.0CommonJS
- react-is 19.2.8CommonJS
- readable-stream 4.7.0CommonJS
Similar popularity
- @ethersproject/solidity 5.8.0CommonJS
- babel-plugin-syntax-dynamic-import 6.18.0CommonJS
- node-sass 9.0.0CommonJS
- chromedriver 152.0.3CommonJS
- jshint 2.13.6CommonJS
- ember-cli-babel 8.3.2CommonJS
- sinon-chai 4.0.1ESM-only
- jasmine-spec-reporter 7.0.0CommonJS