Registry / serialization / differ-cli

differ-cli

JSON →
library0.3.0jsnpmunverified

differ-cli is a command-line interface (CLI) tool built with Node.js, designed to generate visual file differences. It relies on the 'universal-diff' library as its core diffing engine. Currently at version 0.3.0, the package appears to be unmaintained; its underlying 'universal-diff' library has not seen updates since its last commit in February 2015. Consequently, differ-cli utilizes older Node.js module patterns, specifically CommonJS `require`, and is not actively developed or receiving modern updates or security patches. Its primary function remains to compare the contents of two specified files and output their line-by-line differences directly to the console.

npm install differ-cli
INSTALL
IMPORT
SIG · DIFFER-CLI
D
differ-cli
serializationjavascriptv0.3.0
Install
—
Import
—
Disk
—
Pass rate
0/ 6
Env Coverage0 / 6
glibc
18–22
musl
18–22
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 18–226 runs
build_error
glibc
node 18–226 runs
build_error
Code
Verified usage

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

differ
✓ const differ = require('differ-cli');
✗ import differ from 'differ-cli';
This package is CommonJS-only. Attempting to use `import` syntax will result in a runtime error in a non-ESM Node.js environment or require specific configuration for transpilation.
CLI usage
✓ npm install -g differ-cli differ-cli <file1> <file2>
✗ node -e "require('differ-cli')('file1', 'file2')"
While programmatically possible, the primary intended use is directly via the installed global CLI command `differ-cli`.

This example demonstrates how to use `differ-cli` programmatically in a Node.js script to compare two temporary files and print the diff output to the console.

const fs = require('fs'); const path = require('path'); const differ = require('differ-cli'); const file1Path = path.join(__dirname, 'file1.txt'); const file2Path = path.join(__dirname, 'file2.txt'); // Create dummy files for demonstration fs.writeFileSync(file1Path, 'Line 1\nLine 2\nLine 3 old\nLine 4\n'); fs.writeFileSync(file2Path, 'Line 1\nLine 2 modified\nLine 3 new\nLine 5 added\n'); differ(file1Path, file2Path, (err, result) => { if (err) { console.error('Error:', err); } else { console.log('Diff Result:\n', result); } // Clean up dummy files fs.unlinkSync(file1Path); fs.unlinkSync(file2Path); });
differ --version
Debug
Known issues
breakingThe `differ-cli` package and its core dependency `universal-diff` have not been updated since 2015. This means there are no active maintainers, no new features, and no patches for bugs or potential security vulnerabilities. Using it in production is highly discouraged.
fix
Consider using actively maintained diffing libraries (e.g., `diff`, `js-diff`) or relying on built-in `git diff` functionality for modern projects.
affects: >=0.3.0
gotchaThis package is CommonJS-only and does not natively support ES Modules (`import`/`export` syntax). Attempting to import it directly in an ESM context without proper transpilation will lead to runtime errors.
fix
Ensure your project is configured for CommonJS, or use `require()` within an ESM wrapper if absolutely necessary. Prefer modern ESM-compatible alternatives.
affects: >=0.3.0
gotchaDue to its age and lack of maintenance, `differ-cli` may not be compatible with newer Node.js versions, potentially leading to unexpected errors or silent failures.
fix
Test thoroughly in your target Node.js environment. If issues arise, migration to a current diffing library is recommended.
affects: >=0.3.0
Errors
Common errors & fixes
ReferenceError: require is not defined in ES module scope
Attempting to use `require('differ-cli')` within an ES Module (ESM) file, or when `"type": "module"` is set in your `package.json`.
fix
This package is CommonJS only. You must use it in a CommonJS context. If your project is ESM, you may need to wrap the `require` call or use dynamic import `import('differ-cli')` if the package allowed it (which it might not fully support due to its age). The best fix is to use an ESM-compatible diffing library.
differ is not a function
This error can occur if `require('differ-cli')` does not return a function as expected, possibly due to an incorrect import, a changed API, or an environment issue.
fix
Verify that `differ-cli` is installed correctly and that `require('differ-cli')` indeed returns a function in your environment. Check for any global shims or conflicting package names.
Upgrade
Version history
0.3.0latest on npm
Audit
Dependencies
universal-diffrequiredThis is the core diffing engine used by differ-cli.
Agent activity
13 hits · last 30 days
node
10
Amazon
1
Resources
differ-cli — npm install differ-cli · libregistry