Registry / devops / gulp-javascript-obfuscator

gulp-javascript-obfuscator

JSON →
library1.1.6jsnpmunverified

gulp-javascript-obfuscator is a Gulp plugin that integrates the powerful `javascript-obfuscator` library into Gulp build workflows. Currently at version 1.1.6, this package provides a stream-based interface for obfuscating JavaScript files, adding a layer of protection against reverse engineering and making code harder to read. This plugin is typically stable, with its release cadence tied to updates in the underlying `javascript-obfuscator` for feature enhancements and Gulp-specific maintenance. A key differentiator is its seamless integration with `gulp-sourcemaps`, which allows for proper debugging of obfuscated code by automatically generating corresponding source maps. This ensures a robust and maintainable obfuscation process within existing Gulp pipelines and supports chaining with other Gulp plugins like Babel for pre-processing.

npm install gulp-javascript-obfuscator
INSTALL
IMPORT
SIG · GULP-JAVASCRIPT-OB
G
gulp-javascript-obfuscator
devopsjavascriptv1.1.6
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

javascriptObfuscator
const javascriptObfuscator = require('gulp-javascript-obfuscator');
import javascriptObfuscator from 'gulp-javascript-obfuscator';
This is a CommonJS module, primarily used in Gulpfiles which are typically CommonJS. Direct ESM `import` will not work.
gulp
const gulp = require('gulp');
import gulp from 'gulp';
Gulpfiles are traditionally CommonJS modules. `import` syntax is not typically supported without additional transpilation.
sourcemaps
const sourcemaps = require('gulp-sourcemaps');
import sourcemaps from 'gulp-sourcemaps';
Like other Gulp plugins, `gulp-sourcemaps` is imported using CommonJS `require` in a Gulpfile.

This quickstart demonstrates how to set up a Gulp task to obfuscate JavaScript files, incorporating Babel for transpilation and `gulp-sourcemaps` for generating debug-friendly sourcemaps alongside the obfuscated output.

const gulp = require('gulp'); const javascriptObfuscator = require('gulp-javascript-obfuscator'); const sourcemaps = require('gulp-sourcemaps'); const babel = require('@babel/core'); // Optional: for pre-processing JS const babelPresetEnv = require('@babel/preset-env'); // Optional: for Babel preset gulp.task('obfuscate-js', () => { return gulp.src('src/**/*.js') .pipe(sourcemaps.init()) // Initialize sourcemaps before any transformations .pipe(babel({ presets: [babelPresetEnv] })) // Optional: Transpile modern JS to a compatible version .pipe(javascriptObfuscator({ compact: true, // Example option: compact the obfuscated code // Other javascript-obfuscator options can go here // IMPORTANT: Do NOT set `sourceMap: true` here when using gulp-sourcemaps })) .pipe(sourcemaps.write('.')) // Write sourcemaps to the same directory as output .pipe(gulp.dest('dist')); // Output obfuscated and sourcemap files to 'dist' }); // To run this task: npx gulp obfuscate-js
Debug
Known issues
breakingWhen using `gulp-sourcemaps` for source map generation, the `sourceMap` option within `javascript-obfuscator` configurations MUST NOT be set. The plugin handles source map integration automatically, and explicitly setting `sourceMap: true` will cause conflicts or incorrect behavior.
fix
Remove `sourceMap` from the options object passed to `javascriptObfuscator()`. Ensure `sourcemaps.init()` is called before and `sourcemaps.write()` after the obfuscator in the Gulp pipeline.
affects: >=1.1.6
deprecatedThe method of generating source maps by directly setting `sourceMap: true` in the `javascript-obfuscator` options (without `gulp-sourcemaps`) is deprecated. This older approach generates a `.map` file directly into the Gulp stream but is not recommended for future use and may be removed in later versions.
fix
Migrate to using `gulp-sourcemaps` for robust and compatible source map generation. Follow the `gulp-sourcemaps` integration pattern: `pipe(sourcemaps.init()).pipe(javascriptObfuscator()).pipe(sourcemaps.write())`.
affects: >=1.1.6
gotchaOlder Node.js versions (e.g., 13.6 and above) have been reported to cause 'Spread Syntax error' or 'The number of constructor arguments in the derived class must be >= than the number of constructor arguments of its base class' when using `gulp-javascript-obfuscator` due to incompatibilities with underlying dependencies.
fix
If encountering these errors, consider downgrading to a compatible Node.js LTS version (e.g., Node.js 12.x) or updating `gulp-javascript-obfuscator` and its core dependency `javascript-obfuscator` to their latest versions if a fix has been released for your Node.js version.
affects: <=1.1.6 (specific Node.js 13.x versions)
Errors
Common errors & fixes
Error in plugin "gulp-javascript-obfuscator" Message: The number of constructor arguments in the derived class t must be >= than the number of constructor arguments of its base class.
Incompatibility between `javascript-obfuscator`'s internal dependencies and specific Node.js versions (e.g., Node.js 13.6+).
fix
Downgrade your Node.js version to a compatible LTS release (e.g., Node.js 12.x) or check for newer versions of `gulp-javascript-obfuscator` and `javascript-obfuscator` that support your Node.js version.
SyntaxError: Unexpected token ... (related to spread syntax in `chalk` or other dependencies)
Older Node.js environments or misconfigured transpilation pipelines struggling with modern JavaScript syntax used by `javascript-obfuscator` or its sub-dependencies.
fix
Ensure your Node.js version supports the syntax used by the library and its dependencies, or use a transpiler like Babel if targeting older environments. Check `javascript-obfuscator`'s compatibility matrix.
TypeError: javascriptObfuscator is not a function
The `gulp-javascript-obfuscator` module was not correctly `require`d, or the variable name does not match the imported symbol.
fix
Verify that `const javascriptObfuscator = require('gulp-javascript-obfuscator');` is correctly placed and that `javascriptObfuscator` is used as a function in the `.pipe()` chain.
Error: Cannot find module 'vinyl-sourcemaps-apply'
A dependency issue where `gulp-sourcemaps` or `gulp-javascript-obfuscator` cannot find a required sub-dependency for sourcemap processing.
fix
Run `npm install` or `yarn install` again to ensure all transitive dependencies are correctly installed. This can sometimes be resolved by clearing the npm cache (`npm cache clean --force`).
Upgrade
Version history
1.1.6latest on npm
Audit
Dependencies
javascript-obfuscatorrequiredCore dependency for performing the actual JavaScript obfuscation. This plugin is a wrapper around it.
gulp-sourcemapsoptionalHighly recommended for generating source maps, which is essential for debugging obfuscated code. It handles sourcemap generation for the obfuscated output.
gulprequiredPeer dependency for any Gulp plugin to function within a Gulp build system.
Agent activity
4 hits · last 30 days
node
4
Resources
gulp-javascript-obfuscator — npm install gulp-javascript-obfuscator · libregistry