npm-diff

The registry diff command

Table of contents

Synopsis

npm diff [...<paths>]
npm diff --diff=<pkg-name> [...<paths>]
npm diff --diff=<version-a> [--diff=<version-b>] [...<paths>]
npm diff --diff=<spec-a> [--diff=<spec-b>] [...<paths>]
npm diff [--diff-ignore-all-space] [--diff-name-only] [...<paths>]

Description

Similar to its git diff counterpart, this command will print diff patches of files for packages published to the npm registry.

Note that tag names are not valid --diff argument values, if you wish to compare to a published tag, you must use the pkg@tagname syntax.

Filtering files

It’s possible to also specify positional arguments using file names or globs pattern matching in order to limit the result of diff patches to only a subset of files for a given package, e.g:

npm diff --diff=pkg@2 ./lib/ CHANGELOG.md

In the example above the diff output is only going to print contents of files located within the folder ./lib/ and changed lines of code within the CHANGELOG.md file.

Configuration

diff

Defines npm package specifiers to compare using the npm diff command.

This can be specified up to 2 times.

diff-name-only

When set to true running npm diff only returns the names of the files that have any difference.

diff-unified

The number of lines of context to print in the unified diff format output.

diff-ignore-all-space

Ignore whitespace when comparing lines. This ignores differences even if one line has whitespace where the other line has none.

diff-no-prefix

Do not show any source or destination prefix.

diff-src-prefix

Show the given source prefix in diff patches headers instead of using “a/”.

diff-dst-prefix

Show the given source prefix in diff patches headers instead of using “b/”.

diff-text

Treat all files as text.

global

Uses packages from the global space as a source for comparison.

tag

The tag used to fetch the tarball that will be compared with the local file system files when running npm diff with no arguments.

See Also