LinuxCommandLibrary

npm-find-dupes

Find duplicate packages in npm projects

TLDR

List all duplicate packages within node_modules

$ npm find-dupes
copy

Include devDependencies in duplicate detection
$ npm find-dupes --include dev
copy

List all duplicate instances of a specific package in node-modules
$ npm find-dupes [package_name]
copy

Exclude optional dependencies from duplicate detection
$ npm find-dupes --omit optional
copy

Set the logging level for output
$ npm find-dupes --loglevel [silent|error|warn|info|verbose]
copy

Output duplicate information in JSON format
$ npm find-dupes --json
copy

Limit duplicate search to specific scopes
$ npm find-dupes --scope [@scope1,@scope2]
copy

Exclude specific scopes from duplicate detection
$ npm find-dupes --omit-scope [@scope1,@scope2]
copy

SYNOPSIS

npm-find-dupes [options] [path]

PARAMETERS

-p, --production
    Scan only production dependencies, excluding development dependencies.

-d, --development
    Scan only development dependencies, excluding production dependencies.

-s, --show-paths
    Display the full file paths to the duplicate modules detected.

-i, --ignore
    A comma-separated list of glob patterns to ignore when scanning for duplicates.

--json
    Output the scan results in JSON format for programmatic parsing.

--no-color
    Disable colored output in the terminal, useful for non-interactive environments.

-v, --version
    Show the version number of the npm-find-dupes command.

-h, --help
    Display the help message, showing command usage and options.

[path]
    The directory to scan for duplicate npm packages. If omitted, the current working directory is used by default.

DESCRIPTION

npm-find-dupes is a command-line utility for Node.js projects that identifies and lists duplicate package installations within the node_modules directory. It helps developers diagnose issues caused by redundant dependencies, such as increased application bundle size, longer installation times, and potential runtime conflicts arising from multiple versions of the same package. The command scans the dependency tree and reports instances where a package exists multiple times, often under different sub-dependencies, providing visibility into the structure of installed modules. It serves as a diagnostic tool, providing insights necessary for optimizing dependency management and ensuring a leaner, more efficient project.

CAVEATS

npm-find-dupes is a diagnostic tool; it identifies but does not automatically fix duplicate installations. Resolution often requires using npm dedupe or manually adjusting package.json dependencies. Duplicates can occur due to different sub-dependencies requiring varying versions of the same package, or poorly managed dependency trees.

INSTALLATION

To use npm-find-dupes, it typically needs to be installed globally via npm:
npm install -g npm-find-dupes
This makes the npm-find-dupes command available directly in your terminal.

HISTORY

npm-find-dupes is an npm package created to address the common problem of duplicate package installations in Node.js projects. Its development focuses on providing a clear diagnostic view of the dependency tree, helping developers manage and optimize their project's dependencies effectively by highlighting redundant modules.

SEE ALSO

npm ls(1), npm dedupe(1), npm install(1)

Copied to clipboard