← 返回命令列表

Linux command

npm-diff 命令

文本

复制后可按需替换文件名、目录或参数。

常用示例

Compare versions of package

npm diff --diff=[package]@[1.0.0] --diff=[package]@[2.0.0]

Compare local with registry

npm diff --diff=[package-name]

Compare specific files

npm diff --diff=[pkg]@[1.0.0] --diff=[pkg]@[2.0.0] [./file.js]

说明

npm diff shows differences between package versions or between local package and registry. Useful for reviewing changes before updating.

参数

--diff _spec_
Package spec to compare; can be used twice to specify both sides.
--diff-name-only
Show only changed filenames.
--diff-unified _n_
Number of lines of context to show (default 3).
--diff-ignore-all-space
Ignore whitespace when comparing lines.
--diff-no-prefix
Omit source and destination prefixes from output.
--diff-src-prefix _prefix_
Source prefix in output (default "a/").
--diff-dst-prefix _prefix_
Destination prefix in output (default "b/").
--diff-text
Treat all files as text.

FAQ

What is the npm-diff command used for?

npm diff shows differences between package versions or between local package and registry. Useful for reviewing changes before updating.

How do I run a basic npm-diff example?

Run `npm diff --diff=[package]@[1.0.0] --diff=[package]@[2.0.0]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does --diff _spec_ do in npm-diff?

Package spec to compare; can be used twice to specify both sides.