npm-diff

The registry diff command

Table of contents

Synopsis

npm diff [...<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

Define arguments to compare in npm diff.

diff-name-only

Prints only filenames when using npm diff.

diff-unified

The number of lines of context to print in npm diff.

diff-ignore-all-space

Ignore whitespace when comparing lines in npm diff.

diff-no-prefix

Do not show any source or destination prefix in npm diff output.

Note: this causes npm diff to ignore the --diff-src-prefix and --diff-dst-prefix configs.

diff-src-prefix

Source prefix to be used in npm diff output.

diff-dst-prefix

Destination prefix to be used in npm diff output.

diff-text

Treat all files as text in npm diff.

global

Operates in "global" mode, so that packages are installed into the prefix folder instead of the current working directory. See folders for more on the differences in behavior.

tag

If you ask npm to install a package and don't tell it a specific version, then it will install the specified tag.

Also the tag that is added to the package@version specified by the npm tag command, if no explicit tag is given.

When used by the npm diff command, this is the tag used to fetch the tarball that will be compared with the local files by default.

workspace

Enable running a command in the context of the configured workspaces of the current project while filtering by running only the workspaces defined by this configuration option.

Valid values for the workspace config are either:

When set for the npm init command, this may be set to the folder of a workspace which does not yet exist, to create the folder and set it up as a brand new workspace within the project.

This value is not exported to the environment for child processes.

workspaces

Set to true to run the command in the context of all configured workspaces.

Explicitly setting this to false will cause commands like install to ignore workspaces altogether. When not set explicitly:

This value is not exported to the environment for child processes.

include-workspace-root

Include the workspace root when workspaces are enabled for a command.

When false, specifying individual workspaces via the workspace config, or all workspaces via the workspaces flag, will cause npm to operate only on the specified workspaces, and not on the root project.

This value is not exported to the environment for child processes.

See Also