Registry / devops / compile-nodejs

compile-nodejs

JSON →
library2.0.1jsnpmunverified

CompileNodeJS (v2.0.1) is a JavaScript and JSON parsing, minification, compression, and beautification toolkit for Node.js. It wraps uglify-js, @babel/core, @babel/preset-react, and babel-minify into a simple build pipeline. Released as both a CLI and programmatic library, it offers functions to minify files, build directories, and transform package.json and .env files for production. Unlike standalone minifiers, it provides a unified API for complete build automation.

npm install compile-nodejs
INSTALL
IMPORT
SIG · COMPILE-NODEJS
C
compile-nodejs
devopsjavascriptv2.0.1
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

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

compile
const compile = require('compile-nodejs');
import compile from 'compile-nodejs';
CommonJS only; no ES module wrapper.
buildDirectory
compile.buildDirectory(source).then(...)
await compile.buildDirectory() without async
All build methods return Promises.
buildMinify
compile.buildMinify(compile.source('index.js'), compile.destiny('index.js'))
compile.buildMinify('index.js', 'index.js')
Must use source() and destiny() helper functions.

Demonstrates basic usage: require the module, call async functions to build a directory and minify a file.

const compile = require('compile-nodejs'); async function main() { await compile.buildDirectory(compile.source('build')); await compile.buildMinify(compile.source('index.js'), compile.destiny('index.js')); } main().then(() => console.log('Done')).catch(err => console.error(err));
Debug
Known issues
gotchaAll methods are asynchronous and must be awaited.
fix
Use async/await or .then() on all compile calls.
affects: >=2.0
gotchasource() and destiny() helper functions must be used to wrap file paths.
fix
Wrap paths: compile.source('path') and compile.destiny('path').
affects: >=2.0
gotchaThe module is CommonJS only; ES module imports (import) will fail.
fix
Use require().
affects: >=2.0
gotchaDependencies are heavy (Babel, uglify) – install time may be long.
fix
Consider using only needed parts or lighter alternatives.
affects: >=2.0
Errors
Common errors & fixes
TypeError: compile.buildDirectory is not a function
Using ES module import syntax (import) instead of require.
fix
Use const compile = require('compile-nodejs');
Error: Must provide source file path with compile.source()
Passing raw string instead of compile.source() wrapper.
fix
Use compile.source('your-file.js') as argument.
TypeError: Cannot read properties of undefined (reading 'then')
Calling async function without await or .then() inside a non-async context.
fix
Ensure the calling function is async and use await.
Upgrade
Version history
2.0.1latest on npm
Audit
Dependencies
uglify-jsrequiredJavaScript minification
@babel/corerequiredJavaScript transformation and parsing
@babel/preset-reactrequiredReact JSX support
babel-minifyrequiredMinification via Babel
Agent activity
2 hits · last 30 days
node
2
Resources
compile-nodejs — npm install compile-nodejs · libregistry