-
Notifications
You must be signed in to change notification settings - Fork 31
Open
Description
Description
The @pyroscope/nodejs package fails with ERR_REQUIRE_ESM when using the CommonJS build (dist/cjs) due to [email protected] being an ESM-only module.
Error
Error [ERR_REQUIRE_ESM]: require() of ES Module /app/node_modules/@pyroscope/nodejs/node_modules/p-limit/index.js from /app/node_modules/@pyroscope/nodejs/dist/cjs/sourcemapper.js not supported.
Instead change the require of index.js in /app/node_modules/@pyroscope/nodejs/dist/cjs/sourcemapper.js to a dynamic import() which is available in all CommonJS modules.
at Object.<anonymous> (/app/node_modules/@pyroscope/nodejs/dist/cjs/sourcemapper.js:64:35)
Root Cause
p-limitwas upgraded to^7.2.0inpackage.jsonin v0.4.8 (4cad0a4)[email protected]is ESM-only and cannot berequire()'dsrc/sourcemapper.tsline 27 has:import pLimit from 'p-limit';- TypeScript compiles this to
require('p-limit')in the CommonJS build - Runtime fails because ESM modules cannot be required from CommonJS
Reproduction
Environment:
@pyroscope/nodejs: 0.4.8+- Node.js: 20.x or 22.x
- Module system: CommonJS
Steps:
- Install
@pyroscope/nodejsin a CommonJS project - Import and initialize the profiler
- Error occurs when the module loads, regardless of configuration
Workaround
Downgrade or add to package.json:
"resolutions": {
"p-limit": "3.1.0"
}Impact
- Severity: High - breaks CommonJS environments
- Affected versions: 0.4.8+ (when p-limit was upgraded to 7.x)
radko93, igiannoulas-planhat, mmanishh, IggyMi and magandrezsergey-kruglov and mmanishh
Metadata
Metadata
Assignees
Labels
No labels