{"id":45719,"library":"p-queue-cjs","title":"p-queue-cjs","description":"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.","status":"maintenance","version":"7.3.4","language":"javascript","source_language":"en","source_url":"https://github.com/nguyenngoclongdev/p-queue-cjs","tags":["javascript","promise","queue","enqueue","limit","limited","concurrency","throttle","throat","typescript"],"install":[{"cmd":"npm install p-queue-cjs","lang":"bash","label":"npm"},{"cmd":"yarn add p-queue-cjs","lang":"bash","label":"yarn"},{"cmd":"pnpm add p-queue-cjs","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"PQueue extends EventEmitter3 for event handling (e.g., 'active', 'completed', 'error').","package":"eventemitter3","optional":false}],"imports":[{"note":"Default import. Despite being a CJS fork, the package's latest version is ESM-only. Use dynamic import() for CommonJS projects.","wrong":"const PQueue = require('p-queue-cjs')","symbol":"PQueue","correct":"import PQueue from 'p-queue-cjs'"},{"note":"Named import is incorrect; the package exports a default class.","wrong":"import { PQueue } from 'p-queue-cjs'","symbol":"PQueue","correct":"import PQueue from 'p-queue-cjs'"},{"note":"TypeScript only. Options type is exported as a named type, not a value.","wrong":"import { QueueAddOptions } from 'p-queue-cjs'","symbol":"QueueAddOptions","correct":"import type { QueueAddOptions } from 'p-queue-cjs'"}],"quickstart":{"code":"import PQueue from 'p-queue-cjs';\nimport fetch from 'node-fetch';\n\nconst queue = new PQueue({ concurrency: 1 });\n\nasync function fetchJson(url: string): Promise<any> {\n  const response = await fetch(url);\n  return response.json();\n}\n\n(async () => {\n  const result1 = await queue.add(() => fetchJson('https://api.example.com/data1'));\n  console.log('Result 1:', result1);\n  const result2 = await queue.add(() => fetchJson('https://api.example.com/data2'));\n  console.log('Result 2:', result2);\n})();","lang":"typescript","description":"Creates a queue with concurrency 1, adds two async fetch tasks, and logs results sequentially."},"warnings":[{"fix":"Use dynamic import() in CommonJS: const PQueue = (await import('p-queue-cjs')).default; or downgrade to v6 (npm install p-queue-cjs@6).","message":"p-queue-cjs v7 is ESM-only; no longer provides a CommonJS export.","severity":"breaking","affected_versions":">=7.0.0"},{"fix":"Consider migrating to p-queue (ESM) or other alternatives if new features are needed.","message":"The project is in maintenance mode; no new features will be added.","severity":"deprecated","affected_versions":">=7.0.0"},{"fix":"Change to ESM (type: module) or use dynamic import().","message":"Using require() with p-queue-cjs v7 will fail with ERR_REQUIRE_ESM.","severity":"gotcha","affected_versions":">=7.0.0"},{"fix":"Use queue.add(fn, { signal: abortSignal }) instead of queue.add(fn, abortSignal).","message":"The `add` method no longer accepts AbortSignal as a separate argument; it must be passed via options object.","severity":"breaking","affected_versions":">=7.0.0"},{"fix":"Use import type { QueueAddOptions } from 'p-queue-cjs' for type-only import.","message":"When using TypeScript, named import for type QueueAddOptions is required, but runtime import of QueueAddOptions will be undefined.","severity":"gotcha","affected_versions":">=7.0.0"},{"fix":"Use { queue: MyCustomQueue } instead of { queueClass: MyCustomQueue }.","message":"The `queueClass` option is deprecated; use the `queue` option instead.","severity":"deprecated","affected_versions":">=7.0.0"}],"env_vars":null,"search_vec":"'7.3.4':22 'abortsign':52 'api':92 'async':89 'base':47 'cadenc':25 'call':93 'cjs':4,62 'claim':70 'commonj':17,35 'compar':53 'compat':36 'concurr':8,100 'control':9 'current':19 'despit':69 'develop':31 'differenti':33 'enqueu':97 'esm':68,74 'esm-on':73 'featur':30 'focus':60 'fork':10,59 'interv':46 'interval-bas':45 'javascript':94 'key':32 'latest':23 'like':91 'limit':49,88,98,99 'maintain':34 'mainten':26 'mode':27 'nativ':66 'node.js':39 'offer':41 'older':38 'oper':90 'p':2,13,56 'p-queue':12,55 'p-queue-cj':1 'packag':79 'plan':29 'primarili':83 'prioriti':42 'project':40 'promis':5,95 'provid':16 'queu':43 'queue':3,6,14,57,96 'rate':48,87 'rate-limit':86 'releas':24 'ship':80 'stabl':20 'support':18,51,67 'throat':102 'throttl':101 'timeout':44 'type':82 'typescript':81,103 'use':84 'user':63 'v7':77 'version':21","created_at":"2026-06-07T12:56:23.737497+00:00","updated_at":"2026-06-07T12:56:23.737497+00:00","problems":[{"fix":"Use dynamic import: const PQueue = (await import('p-queue-cjs')).default;","cause":"Using require() on p-queue-cjs v7+ which is ESM-only.","error":"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."},{"fix":"Use import PQueue from 'p-queue-cjs'.","cause":"Using named import { PQueue } instead of default import.","error":"TypeError: PQueue is not a constructor"},{"fix":"Add 'type': 'module' to package.json or use a bundler/transpiler.","cause":"Running p-queue-cjs in a CommonJS environment without transpilation or ESM support.","error":"SyntaxError: Unexpected token 'export'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://nguyenngoclongdev.github.io","github":"https://github.com/nguyenngoclongdev/p-queue-cjs","docs":null,"changelog":null,"pypi":null,"npm":"p-queue-cjs","openapi_spec":null,"status_page":null,"smithery":null,"categories":["devops"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-07","next_check":"2026-09-05","install_tag":null}}