Start a project

Tool 122 of 194 · JavaScript

npm Dependency Graph & Duplicates

See what a package-lock.json actually installs: duplicated packages and whether one version could serve them all, why any package is there, licences and depth, without running npm.

npm Dependency Graph & Duplicates at a glanceIllustration: 1, package-lock.json; 2, processed in your browser; 3, Dependency graph.npm Dependency Graph & Duplicates{ }1package-lock.json/26 · 62 hosts3Dependency graph2In yourbrowser
1 package-lock.json 2 processed on your device 3 Dependency graph

npm Dependency Graph & Duplicates

Your lockfile

Overview

    Installed more than once

    PackageVersionsCopiesDedupeRanges asked for

    Why is it installed?

    Dependency chains (like npm explain)

    Every package

    PackageVersionDepthTypeLicenceRequired by

    01

    What it does

    Reads package-lock.json v1 to v3, resolves dependencies the way Node does, and shows duplicates, why each package is installed, licences and depth.

    • Lockfile versions 1, 2 and 3, with workspaces, links and npm: aliases
    • Dependencies resolved through nested node_modules like Node's require
    • Duplicates with a semver check of whether one version satisfies every range
    • Why a package is installed, as chains and a reverse dependency graph

    02

    Private by design

    Everything happens in your browser. Nothing you type, paste or upload is sent anywhere, and it keeps working offline once the page has loaded.

    03

    What you get

    Duplicate and package tables, why-chains, a graph and a CSV, with a Copy and a Download button on every result.

    • npm
    • package-lock.json
    • Dependencies
    • Node.js

    Why it matters

    A package-lock.json records every package npm installed and where, but at thousands of lines it's hard to answer simple questions from it: why is this package here, why are there three copies of it, and what licences am I shipping? npm explain and npm ls answer some of them, but only in a checked-out project with node_modules installed.

    This viewer reads the lockfile on its own. It rebuilds the dependency graph by resolving each dependency the way Node does, looking in the nearest node_modules folder and then each parent folder in turn, so nested copies, workspaces and aliased packages come out right. For every package installed more than once it collects the version ranges the dependents asked for and checks with semver whether a single version would satisfy them all, which is when npm dedupe can merge the copies. Pick any package to see the chain of dependencies that pulled it in, from your package.json down. Everything runs in your browser.

    How it works

    1. InputA package-lock.json
    2. In your browserDependencies resolved the way Node does
    3. OutputDuplicates, why-chains, depth and licences

    Where it fits in a designer's workflow

    1. Plan
    2. Design
    3. Build
    4. Test
    5. Launch
    Trimming dependencies and answering 'why is this installed?'.

    By the numbers

    Installed packages by depth in the sample lockfileDepth 1: 7 packages; Depth 2: 16 packages; Depth 3: 12 packages; Depth 4: 4 packages; Depth 5: 1 packageDepth 17 packagesDepth 216 packagesDepth 312 packagesDepth 44 packagesDepth 51 package
    Counted by this tool from its sample package-lock.json: 40 packages (18 production, 21 dev, 1 optional). Depth 1 is what your package.json asks for; everything deeper came in with those. 3 packages are installed more than once: ms (2.0.0, 2.1.3, 2.1.2), debug (2.6.9, 4.3.6), picocolors (1.0.0, 1.0.1). Source: npm docs: package-lock.json; Node.js: loading from node_modules.
    Show the numbers as a table
    PackageVersionsCopiesDedupe
    ms2.0.0, 2.1.3, 2.1.23The ranges need 3 versions
    debug2.6.9, 4.3.62The ranges need 2 versions
    picocolors1.0.0, 1.0.12npm dedupe could use 1.0.1

    How to use it

    1. Drop your package-lock.json, or paste it.
    2. Read the overview and the duplicates table.
    3. Type a package name to see why it's installed.
    4. Download the CSV for a licence review.

    FAQ

    What does 'npm dedupe could use 1.2.3' mean?

    Every package that depends on the duplicated one asked for a range that 1.2.3 satisfies, so npm dedupe (or a fresh install) can usually keep one copy. When the ranges can't all be met by one version, copies are needed, and the fix is updating the dependent that asks for the old range.

    Why is a dev dependency of a package not listed?

    npm never installs the devDependencies of your dependencies, only those of your own project and its workspaces, so the lockfile doesn't contain them.

    Do I need package.json too?

    Not for lockfile v2 or v3, which record your own dependencies in the root entry. Version 1 lockfiles don't, so add package.json for accurate dev and production splits.

    What about yarn.lock or pnpm-lock.yaml?

    Not yet: they record resolution differently. This tool reads npm's package-lock.json and npm-shrinkwrap.json.

    Is my lockfile uploaded?

    No. It's read in your browser and nothing is sent anywhere. The sample is a made-up project.

    Work with me

    Want a site that gets these right?

    I build fast, accessible websites and web apps that pass these checks from day one. Tell me about your project and I'll reply personally with honest next steps.

    All developer tools · Back to leej.uk