-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Labels
Description
Expected Behavior
The CLI should obfuscate JavaScript files without errors, as it did in version 4.1.1.
Current Behavior
The CLI fails immediately with an ESM compatibility error when trying to load the multimatch dependency.
Steps to Reproduce
- Install Node.js v20.x
- Run
npm install -g javascript-obfuscator@4.2.0 - Create a simple JS file:
echo "console.log('test')" > test.js - Run
javascript-obfuscator test.js --output out.js - Error occurs
My Environment
- Obfuscator version used: 4.2.0
- Node version used: v20.15.1 (Alpine Linux / Docker)
Stack trace
Error [ERR_REQUIRE_ESM]: require() of ES Module /usr/local/lib/node_modules/javascript-obfuscator/node_modules/multimatch/index.js from /usr/local/lib/node_modules/javascript-obfuscator/dist/index.cli.js not supported.
Instead change the require of index.js in /usr/local/lib/node_modules/javascript-obfuscator/dist/index.cli.js to a dynamic import() which is available in all CommonJS modules.
at 8014 (/usr/local/lib/node_modules/javascript-obfuscator/dist/index.cli.js:2:520165)
at r (/usr/local/lib/node_modules/javascript-obfuscator/dist/index.cli.js:2:615438)
at 9632 (/usr/local/lib/node_modules/javascript-obfuscator/dist/index.cli.js:2:586510)
at r (/usr/local/lib/node_modules/javascript-obfuscator/dist/index.cli.js:2:615438)
at 2676 (/usr/local/lib/node_modules/javascript-obfuscator/dist/index.cli.js:2:143491)
Minimal working example that will help to reproduce issue
# Any JavaScript file will trigger the error
echo "console.log('hello')" > test.js
javascript-obfuscator test.js --output out.js
Root cause: The multimatch dependency was likely updated to an ESM-only version which cannot be required() from CommonJS.
Workaround: Pin to version 4.1.1Reactions are currently unavailable