npm-outdated

检查过时的包

选择 CLI 版本:

概要

Synopsis

npm outdated [<package-spec> ...]

描述

Description

此命令将检查注册表以查看当前是否有任何(或特定)已安装的包已过时。

This command will check the registry to see if any (or, specific) installed packages are currently outdated.

默认情况下,仅显示根项目的直接依赖和配置的工作区的直接依赖。也可以使用 --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 显示当前安装的版本。

    wanted is the maximum version of the package that satisfies the semver range specified in package.json. If there's no available semver range (i.e. you're running npm outdated --global, or the package isn't included in package.json), then wanted shows the currently-installed version.

  • latest 是在注册表中标记为最新的包的版本。在没有特殊配置的情况下运行 npm publish 将发布带有 latest 的 dist-tag 的包。这可能是也可能不是包的最高版本,或者是最近发布的包版本,这取决于包的开发者如何管理最新的 dist-tag

    latest is the version of the package tagged as latest in the registry. Running npm publish with no special configuration will publish the package with a dist-tag of latest. This may or may not be the maximum version of the package, or the most-recently published version of the package, depending on how the package's developer manages the latest dist-tag.

  • location 是包在物理树中的位置。

    location is where in the physical tree the package is located.

  • depended by 显示哪个包依赖于显示的依赖

    depended by shows which package depends on the displayed dependency

  • package type(使用 --long / -l 时)告诉你这个包是 dependency 还是 dev/peer/optional 依赖。未包含在 package.json 中的包始终标记为 dependencies

    package type (when using --long / -l) tells you whether this package is a dependency or a dev/peer/optional dependency. Packages not included in package.json are always marked dependencies.

  • homepage(使用 --long / -l 时)是包的包中包含的 homepage

    homepage (when using --long / -l) is the homepage value contained in the package's packument

  • 红色表示有更新的版本符合你的 semver 要求,因此你应该立即更新。

    Red means there's a newer version matching your semver requirements, so you should update now.

  • 黄色表示有高于你的 semver 要求的较新版本(通常是新的主要版本或新的 0.x 次要版本),因此请谨慎操作。

    Yellow indicates that there's a newer version above your semver requirements (usually new major, or new 0.x minor) so proceed with caution.

一个示例

An example

$ npm outdated
Package Current Wanted Latest Location Depended by
glob 5.0.15 5.0.15 6.0.1 node_modules/glob dependent-package-name
nothingness 0.0.3 git git node_modules/nothingness dependent-package-name
npm 3.5.1 3.5.2 3.5.1 node_modules/npm dependent-package-name
local-dev 0.0.3 linked linked local-dev dependent-package-name
once 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 安装超出 semver 范围的 glob@6

    glob requires ^5, which prevents npm from installing glob@6, which is outside the semver range.

  • Git 依赖总是会被重新安装,因为它们是如何指定的。安装的 committish 可能满足依赖说明符(如果它是不可变的,例如提交 SHA),也可能不满足,因此 npm outdatednpm update 必须获取 Git 存储库进行检查。这就是为什么当前重新安装 Git 依赖总是会强制进行新的克隆和安装。

    Git dependencies will always be reinstalled, because of how they're specified. The installed committish might satisfy the dependency specifier (if it's something immutable, like a commit SHA), or it might not, so npm outdated and npm update have to fetch Git repos to check. This is why currently doing a reinstall of a Git dependency always forces a new clone and install.

  • npm@3.5.2 被标记为 "wanted",但是 "latest" 是 npm@3.5.1,因为 npm 使用 dist-tags 来管理它的 latestnext 发布通道。npm update 将安装最新版本,但 npm install npm(没有 semver 范围)将安装标记为 latest 的任何内容。

    npm@3.5.2 is marked as "wanted", but "latest" is npm@3.5.1 because npm uses dist-tags to manage its latest and next release channels. npm update will install the newest version, but npm install npm (with no semver range) will install whatever's tagged as latest.

  • once 已经过时了。从头开始重新安装 node_modules 或运行 npm update 将使其符合规范。

    once is just plain out of date. Reinstalling node_modules from scratch or running npm update will bring it up to spec.

配置

Configuration

all

  • 默认值:false

    Default: false

  • 类型:布尔值

    Type: Boolean

运行 npm outdatednpm 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

  • 默认值:false

    Default: false

  • 类型:布尔值

    Type: Boolean

是否输出 JSON 数据,而不是正常输出。

Whether or not to output JSON data, rather than the normal output.

  • npm pkg set 中,它可以使用 JSON.parse() 解析集合值,然后再将它们保存到你的 package.json

    In npm pkg set it enables parsing set values with JSON.parse() before saving them to your package.json.

并非所有 npm 命令都支持。

Not supported by all npm commands.

long

  • 默认值:false

    Default: false

  • 类型:布尔值

    Type: Boolean

lssearchhelp-search 中显示扩展信息。

Show extended information in ls, search, and help-search.

parseable

  • 默认值:false

    Default: false

  • 类型:布尔值

    Type: Boolean

从写入标准输出的命令输出可解析的结果。对于 npm search,这将是制表符分隔的表格格式。

Output parseable results from commands that write to standard output. For npm search, this will be tab-separated table format.

global

  • 默认值:false

    Default: false

  • 类型:布尔值

    Type: Boolean

在 "global" 模式下运行,以便将包安装到 prefix 文件夹而不是当前工作目录。有关行为差异的更多信息,请参见 文件夹

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 文件夹,而不是当前工作目录。

    packages are installed into the {prefix}/lib/node_modules folder, instead of the current working directory.

  • bin 文件链接到 {prefix}/bin

    bin files are linked to {prefix}/bin

  • 手册页链接到 {prefix}/share/man

    man pages are linked to {prefix}/share/man

workspace

  • 默认值:

    Default:

  • 类型:字符串(可以设置多次)

    Type: String (can be set multiple times)

启用在当前项目的已配置工作区的上下文中运行命令,同时通过仅运行此配置选项定义的工作区进行过滤。

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:

  • 工作区名称

    Workspace names

  • 工作区目录的路径

    Path to a workspace directory

  • 父工作区目录的路径(将导致选择该文件夹中的所有工作区)

    Path to a parent workspace directory (will result in selecting all workspaces within that folder)

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.

也可以看看

See Also

npm 中文网 - 粤ICP备13048890号