javascript-obfuscator: ReferenceError: Given config path must be a valid file path

Not sure what mistake I’m making but I’ve tried giving it relative (to curr working dir), absolute, and input file dir. However, it keeps throwing this error.

The contents are copy and paste of all possible params in Readme.

cd /text

./node_modules/javascript-obfuscator/bin/javascript-obfuscator ./tmp/js.merged.js --config obfuscator.js 

/text/node_modules/javascript-obfuscator/dist/webpack:/src/cli/utils/CLIUtils.ts:58
                throw new ReferenceError('Given config path must be a valid file path');
                      ^
ReferenceError: Given config path must be a valid file path
    at Function.value (/text/node_modules/javascript-obfuscator/dist/webpack:/src/cli/utils/CLIUtils.ts:58:23)
    at e.value (/text/node_modules/javascript-obfuscator/dist/webpack:/src/cli/JavaScriptObfuscatorCLI.ts:178:93)
    at e.value (/text/node_modules/javascript-obfuscator/dist/webpack:/src/cli/JavaScriptObfuscatorCLI.ts:376:58)
    at e.value (/text/node_modules/javascript-obfuscator/dist/webpack:/src/cli/JavaScriptObfuscatorCLI.ts:354:35)
    at e.value (/text/node_modules/javascript-obfuscator/dist/webpack:/src/cli/JavaScriptObfuscatorCLI.ts:168:35)
    at Function.value (/text/node_modules/javascript-obfuscator/dist/webpack:/src/JavaScriptObfuscatorFacade.ts:42:5)
    at Object.<anonymous> (/text/node_modules/javascript-obfuscator/bin/javascript-obfuscator:3:26)
    at Module._compile (module.js:641:30)
    at Object.Module._extensions..js (module.js:652:10)
    at Module.load (module.js:560:32)

also,

cat ./obfuscator.js 
{
    compact: true,
    controlFlowFlattening: false,
    controlFlowFlatteningThreshold: 0.75,
    deadCodeInjection: false,
    deadCodeInjectionThreshold: 0.4,
    debugProtection: false,
    debugProtectionInterval: false,
    disableConsoleOutput: false,
    domainLock: [],
    identifierNamesGenerator: 'hexadecimal',
    identifiersPrefix: '',
    log: false,
    renameGlobals: false,
    reservedNames: [],
    rotateStringArray: true,
    seed: 0,
    selfDefending: false,
    sourceMap: false,
    sourceMapBaseUrl: '',
    sourceMapFileName: '',
    sourceMapMode: 'separate',
    stringArray: true,
    stringArrayEncoding: false,
    stringArrayThreshold: 0.75,
    target: 'browser',
    transformObjectKeys: false,
    unicodeEscapeSequence: false
}

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 15 (8 by maintainers)

Most upvoted comments

I’ll check it.

Wow, it’s very strange.

Thanks.

I had copied and pasted the exact config you have in Readme. But, you were right, adding module.exports = {…} resolved it.