选择命令行版本:
🌐 Synopsis
npm outdated [<package-spec> ...]
🌐 Description
此命令将检查注册表以查看当前是否有任何(或特定)已安装的包已过时。
🌐 This command will check the registry to see if any (or, specific) installed packages are currently outdated.
默认情况下,仅显示根项目的直接依赖以及你配置的 workspaces 的直接依赖。也可以使用 --all 来查找所有过时的元依赖。
🌐 By default, only the direct dependencies of the root project and direct dependencies of your configured workspaces are shown. Use --all to find all outdated meta-dependencies as well.
在输出中:
🌐 In the output:
wanted 是满足 package.json 中指定的 semver 范围的最大版本。如果没有可用的 semver 范围(例如,你正在运行 npm outdated --global,或者该包未包含在 package.json 中),那么 wanted 会显示当前已安装的版本。latest 是在注册表中标记为最新版本的包。运行 npm publish 并且没有特殊配置时,将会以 latest 的 dist-tag 发布该包。该版本可能是包的最大版本,也可能是最新发布的版本,这取决于包的开发者如何管理最新的 dist-tag。location 表示软件包在物理树中的位置。depended by 显示哪个软件包依赖于所显示的依赖package type(在使用 --long / -l 时)会告诉你这个包是 dependency 还是开发/同伴/可选依赖。未包含在 package.json 中的包总是标记为 dependencies。homepage(当使用 --long / -l 时)是包的 packument 中包含的 homepage 值depended by location(在使用 --long / -l 时)显示依赖于所显示依赖的软件包的位置🌐 An example
$ npm outdatedPackage Current Wanted Latest Location Depended byglob 5.0.15 5.0.15 6.0.1 node_modules/glob dependent-package-namenothingness 0.0.3 git git node_modules/nothingness dependent-package-namenpm 3.5.1 3.5.2 3.5.1 node_modules/npm dependent-package-namelocal-dev 0.0.3 linked linked local-dev dependent-package-nameonce 1.3.2 1.3.3 1.3.3 node_modules/once dependent-package-name
使用这些 dependencies:
🌐 With these dependencies:
{"glob": "^5.0.15","nothingness": "github:othiym23/nothingness#master","npm": "^3.5.1","once": "^1.3.1"}
需要注意的几点:
🌐 A few things to note:
glob 需要 ^5,这导致 npm 无法安装 glob@6,因为它不在 semver 范围内。npm outdated 和 npm update 必须获取 Git 仓库以进行检查。这就是为什么目前重新安装 Git 依赖总是会强制进行新的克隆和安装的原因。npm@3.5.2 被标记为“所需”,但“最新”是 npm@3.5.1,因为 npm 使用 dist-tags 来管理它的 latest 和 next 发布渠道。npm update 将安装最新版本,但 npm install npm(没有语义化版本范围)将安装被标记为 latest 的版本。once 已经过时了。重新从头安装 node_modules 或运行 npm update 就可以使其符合规范。🌐 Configuration
all在运行 npm outdated 和 npm ls 时,设置 --all 将显示所有过时或已安装的软件包,而不仅仅是当前项目直接依赖的那些包。
🌐 When running npm outdated and npm ls, setting --all will show all outdated or installed packages, rather than only those directly depended upon by the current project.
json是否输出 JSON 数据,而不是正常输出。
🌐 Whether or not to output JSON data, rather than the normal output.
npm pkg set 中,它可以在将值保存到你的 package.json 之前使用 JSON.parse() 解析设置的值。并非所有 npm 命令都支持。
🌐 Not supported by all npm commands.
long在 ls、search 和 help-search 中显示扩展信息。
🌐 Show extended information in ls, search, and help-search.
parseable从写入标准输出的命令中输出可解析的结果。对于 npm search,这将是制表符分隔的表格格式。
🌐 Output parseable results from commands that write to standard output. For npm search, this will be tab-separated table format.
global以“全局”模式运行,因此软件包会安装到 prefix 文件夹中,而不是当前工作目录。有关行为差异的更多信息,请参见 folders。
🌐 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.
{prefix}/lib/node_modules 文件夹中,而不是当前工作目录。{prefix}/bin 关联{prefix}/share/manworkspace启用在当前项目的已配置工作区的上下文中运行命令,同时通过仅运行此配置选项定义的工作区进行过滤。
🌐 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.
workspace 配置的有效值为以下之一:
🌐 Valid values for the workspace config are either:
对于 npm init 命令设置时,可以将其设置为一个尚不存在的工作区文件夹,以创建该文件夹并将其作为项目内全新的工作区进行设置。
🌐 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.
before如果传递给 npm install,将重建 npm 树,使得只安装在指定日期当日或之前可用的版本。如果当前依赖集没有可用版本,该命令将报错。
🌐 If passed to npm install, will rebuild the npm tree such that only versions that were available on or before the given date are installed. If there are no versions available for the current set of dependencies, the command will error.
如果请求的版本是 dist-tag,且给定的标签未通过 --before 过滤器,则将使用小于或等于该标签的最新版本。例如,foo@latest 可能会安装 foo@1.2,即使 latest 是 2.0。
🌐 If the requested version is a dist-tag and the given tag does not pass the --before filter, the most recent version less than or equal to that tag will be used. For example, foo@latest might install foo@1.2 even though latest is 2.0.
🌐 See Also