Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslnode 18–226 runs
build_error
glibcnode 18–226 runs
build_error
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
pEvery
✓ import pEvery from 'p-every';
✗ import { pEvery } from 'p-every';
As a utility function, p-every is likely a default export in its ESM form. Named import might fail.
pEvery
✓ const pEvery = require('p-every');
✗ const { pEvery } = require('p-every');
Version 2.0.0 primarily uses CommonJS `require()`, treating `pEvery` as a default export from the module. Be aware that newer major versions of similar `p-*` packages have transitioned to ESM-only.
This quickstart demonstrates how to use `p-every` to check if all items in an array of promises (or values) satisfy an asynchronous test condition, with optional concurrency control.
import pEvery from 'p-every';
const getCapital = async (country) => {
// Simulate an async operation, e.g., fetching from an API
const capitals = {
'Norway': { name: 'Oslo', continent: 'Europe' },
'Thailand': { name: 'Bangkok', continent: 'Asia' },
'Germany': { name: 'Berlin', continent: 'Europe' },
'Japan': { name: 'Tokyo', continent: 'Asia' }
};
return new Promise(resolve => setTimeout(() => {
const info = Object.values(capitals).find(c => c.name.includes(country) || country.includes(c.name));
resolve(info);
}, 50));
};
const getContinent = async (place) => {
// Simulate an async operation for continent lookup
const continents = {
'Oslo, Norway': 'europe',
'Bangkok, Thailand': 'asia',
'Berlin, Germany': 'europe',
'Tokyo, Japan': 'asia'
};
return new Promise(resolve => setTimeout(() => {
resolve(continents[place]);
}, 20));
};
(async () => {
const places = [
getCapital('Norway').then(info => `${info.name}, ${'Norway'}`),
'Bangkok, Thailand',
'Berlin, Germany',
'Tokyo, Japan'
];
const testFunction = async place => {
const continent = await getContinent(place);
return continent === 'europe';
};
const result = await pEvery(places, testFunction, { concurrency: 2 });
console.log('Are all places in Europe?', result);
//=> false (because Bangkok and Tokyo are in Asia)
const allEuropeanPlaces = [
'Oslo, Norway',
'Berlin, Germany'
];
const allEuropeanResult = await pEvery(allEuropeanPlaces, testFunction);
console.log('Are all European places in Europe?', allEuropeanResult);
//=> true
})();
Debug
Known issues
breakingAs a major version bump, `p-every@2.0.0` likely includes breaking changes from `1.x.x` versions, adhering to semantic versioning principles. Specific details would typically be found in a changelog or release notes on the GitHub repository. Users upgrading from `1.x.x` should review their usage.fixConsult the project's GitHub releases or changelog (if available) for migration guidance when upgrading from `p-every@1.x.x`.
affects: >=2.0.0
gotchaFuture major versions of `p-every` may transition to being pure ES Module (ESM) packages, similar to other related `p-*` libraries (e.g., `p-limit@4.0.0+`). This means `require('p-every')` will no longer work and you will need to use `import pEvery from 'p-every'` in an ESM context.fixTo prepare for a potential ESM-only future, ensure your project supports ES Modules. This typically involves setting `"type": "module"` in your `package.json` and using `import` statements. If still in CommonJS, you might need to use dynamic `import()` or stick to an older CommonJS-compatible version.
affects: Future major versions (e.g., >=3.0.0)
Errors
Common errors & fixes
Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: /path/to/node_modules/p-every/index.js
Attempting to `require()` an ESM-only version of `p-every` from a CommonJS module.
fixEither convert your consuming module to ESM (by adding `"type": "module"` to your `package.json` and using `import pEvery from 'p-every';`) or use dynamic `await import('p-every')` if remaining in CommonJS. Alternatively, if available, downgrade to a CommonJS-compatible version. TypeError: pEvery is not a function
Incorrectly importing `pEvery` as a named export (`import { pEvery } from 'p-every';`) when it is a default export.
fixUse a default import: `import pEvery from 'p-every';`. If using CommonJS, ensure you are not destructuring: `const pEvery = require('p-every');`. TypeError: testFunction is not a function
The `testFunction` argument passed to `pEvery` is not a valid function or cannot be awaited.
fixEnsure `testFunction` is a correctly defined and callable function, typically an `async` function or one that returns a Promise or a boolean value.
Audit
Dependencies
No dependency data recorded yet.