-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Open
Description
Bug Description
The @agent-tars/cli
package fails to run on Node.js v18, v20, and v22 due to an ESM/CommonJS incompatibility with the imagemin-mozjpeg
dependency.
Error Message
Error [ERR_REQUIRE_ESM]: require() of ES Module /Users/sbhavani/.nvm/versions/node/v18.20.8/lib/node_modules/@agent-tars/cli/node_modules/imagemin-mozjpeg/index.js from /Users/sbhavani/.nvm/versions/node/v18.20.8/lib/node_modules/@agent-tars/cli/node_modules/@agent-tars/core/dist/index.js not supported.
Instead change the require of /Users/sbhavani/.nvm/versions/node/v18.20.8/lib/node_modules/@agent-tars/cli/node_modules/imagemin-mozjpeg/index.js in /Users/sbhavani/.nvm/versions/node/v18.20.8/lib/node_modules/@agent-tars/core/dist/index.js to a dynamic import() which is available in all CommonJS modules.
at ./src/shared/utils.ts (/Users/sbhavani/.nvm/versions/node/v18.20.8/lib/node_modules/@agent-tars/cli/node_modules/@agent-tars/core/dist/index.js:134699:59)
Steps to Reproduce
- Install
@agent-tars/cli
globally:npm install -g @agent-tars/cli
- Run any agent-tars command:
agent-tars --help
- Error occurs immediately
Environment
- Node.js versions tested: v18.20.8, v20.18.3, v22.18.0
- npm version: 10.8.2
- OS: macOS (Darwin 24.6.0)
- @agent-tars/cli version: Latest (0.3.0-beta.12)
Root Cause
The issue appears to be in the webpack bundling configuration. The bundled CommonJS code is attempting to require()
the imagemin-mozjpeg
package, which is now an ES module only. This creates an incompatibility that prevents the CLI from running.
The error occurs at:
- File:
@agent-tars/core/dist/index.js:134699
- Location:
./src/shared/utils.ts
Suggested Fix
The bundling configuration needs to be updated to either:
- Use dynamic
import()
for ESM-only dependencies likeimagemin-mozjpeg
- Exclude ESM-only dependencies from the webpack bundle and load them dynamically at runtime
- Convert the entire package to ESM format
Workaround
Currently, there is no working workaround. The package is unusable across all tested Node.js versions.
Metadata
Metadata
Assignees
Labels
No labels