The package is not marked as an ES module, on a Node.js without detection
CommonWithout "type": "module", a .js file is CommonJS. Node.js before 22.7.0 (or 20.19.0 on the 20 line) does not look at the code to decide otherwise.
Confirm
node -v; node -p "require('./package.json').type"An older Node.js, and undefined or commonjs as the type
Fix
- Add "type": "module" to package.json, then rename any file that still uses require() to .cjs.
- Or rename just this file to .mjs.
- Upgrading Node.js also helps, but set the type anyway: detection costs a reparse and prints a warning.