Registry / devops / p-queue-cjs

p-queue-cjs

JSON →
library7.3.4jsnpmunverified

Promise queue with concurrency control, forked from p-queue to provide CommonJS support. Current stable version: 7.3.4 (latest). Release cadence: maintenance mode, no planned feature development. Key differentiators: maintains CommonJS compatibility for older Node.js projects, offers priority queuing, timeout, interval-based rate limiting, and supports AbortSignal. Compared to p-queue, this fork focuses on CJS users. Does not natively support ESM despite claiming to be ESM-only in v7; the package ships TypeScript types. Primarily used for rate-limiting async operations like API calls.

npm install p-queue-cjs
INSTALL
IMPORT
SIG · P-QUEUE-CJS
P
p-queue-cjs
devopsjavascriptv7.3.4
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

PQueue
import PQueue from 'p-queue-cjs'
const PQueue = require('p-queue-cjs')
Default import. Despite being a CJS fork, the package's latest version is ESM-only. Use dynamic import() for CommonJS projects.
PQueue
import PQueue from 'p-queue-cjs'
import { PQueue } from 'p-queue-cjs'
Named import is incorrect; the package exports a default class.
QueueAddOptions
import type { QueueAddOptions } from 'p-queue-cjs'
import { QueueAddOptions } from 'p-queue-cjs'
TypeScript only. Options type is exported as a named type, not a value.

Creates a queue with concurrency 1, adds two async fetch tasks, and logs results sequentially.

import PQueue from 'p-queue-cjs'; import fetch from 'node-fetch'; const queue = new PQueue({ concurrency: 1 }); async function fetchJson(url: string): Promise<any> { const response = await fetch(url); return response.json(); } (async () => { const result1 = await queue.add(() => fetchJson('https://api.example.com/data1')); console.log('Result 1:', result1); const result2 = await queue.add(() => fetchJson('https://api.example.com/data2')); console.log('Result 2:', result2); })();
Debug
Known issues
breakingp-queue-cjs v7 is ESM-only; no longer provides a CommonJS export.
fix
Use dynamic import() in CommonJS: const PQueue = (await import('p-queue-cjs')).default; or downgrade to v6 (npm install p-queue-cjs@6).
affects: >=7.0.0
deprecatedThe project is in maintenance mode; no new features will be added.
fix
Consider migrating to p-queue (ESM) or other alternatives if new features are needed.
affects: >=7.0.0
gotchaUsing require() with p-queue-cjs v7 will fail with ERR_REQUIRE_ESM.
fix
Change to ESM (type: module) or use dynamic import().
affects: >=7.0.0
breakingThe `add` method no longer accepts AbortSignal as a separate argument; it must be passed via options object.
fix
Use queue.add(fn, { signal: abortSignal }) instead of queue.add(fn, abortSignal).
affects: >=7.0.0
gotchaWhen using TypeScript, named import for type QueueAddOptions is required, but runtime import of QueueAddOptions will be undefined.
fix
Use import type { QueueAddOptions } from 'p-queue-cjs' for type-only import.
affects: >=7.0.0
deprecatedThe `queueClass` option is deprecated; use the `queue` option instead.
fix
Use { queue: MyCustomQueue } instead of { queueClass: MyCustomQueue }.
affects: >=7.0.0
Errors
Common errors & fixes
Error [ERR_REQUIRE_ESM]: require() of ES Module /path/to/node_modules/p-queue-cjs/dist/index.js from /path/to/project/index.js not supported.
Using require() on p-queue-cjs v7+ which is ESM-only.
fix
Use dynamic import: const PQueue = (await import('p-queue-cjs')).default;
TypeError: PQueue is not a constructor
Using named import { PQueue } instead of default import.
fix
Use import PQueue from 'p-queue-cjs'.
SyntaxError: Unexpected token 'export'
Running p-queue-cjs in a CommonJS environment without transpilation or ESM support.
fix
Add 'type': 'module' to package.json or use a bundler/transpiler.
Upgrade
Version history
7.3.4latest on npm
Audit
Dependencies
eventemitter3requiredPQueue extends EventEmitter3 for event handling (e.g., 'active', 'completed', 'error').
Agent activity
2 hits · last 30 days
node
2
Resources
p-queue-cjs — npm install p-queue-cjs · libregistry