npm-pack

从包创建 tarball

选择 CLI 版本:

概要

Synopsis

npm pack <package-spec>

配置

Configuration

dry-run

  • 默认值:false

    Default: false

  • 类型:布尔值

    Type: Boolean

表示你不希望 npm 进行任何更改,并且它应该只报告它会做的事情。这可以传递到任何修改本地安装的命令中,例如 installupdatededupeuninstall 以及 packpublish

Indicates that you don't want npm to make any changes and that it should only report what it would have done. This can be passed into any of the commands that modify your local installation, eg, install, update, dedupe, uninstall, as well as pack and publish.

注意:其他网络相关命令不支持此功能,例如 dist-tagsowner 等。

Note: This is NOT honored by other network related commands, eg dist-tags, owner, etc.

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.

pack-destination

  • 默认值:"."

    Default: "."

  • 类型:字符串

    Type: String

npm pack 将保存 tarball 的目录。

Directory in which npm pack will save tarballs.

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.

workspaces

  • 默认值:null

    Default: null

  • 类型:空值或布尔值

    Type: null or Boolean

设置为 true 可在所有已配置工作区的上下文中运行该命令。

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

显式将此设置为 false 将导致像 install 这样的命令完全忽略工作区。未明确设置时:

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

  • node_modules 树上运行的命令(安装、更新等)会将工作区链接到 node_modules 文件夹。* 执行其他操作(测试、执行、发布等)的命令将在根项目上运行,除非在 workspace 配置中指定了一个或多个工作区。

    Commands that operate on the node_modules tree (install, update, etc.) will link workspaces into the node_modules folder. - Commands that do other things (test, exec, publish, etc.) will operate on the root project, unless one or more workspaces are specified in the workspace config.

此值不会导出到子进程的环境中。

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

include-workspace-root

  • 默认值:false

    Default: false

  • 类型:布尔值

    Type: Boolean

为命令启用工作区时包括工作区根。

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

当为 false 时,通过 workspace 配置指定单个工作区,或通过 workspaces 标志指定所有工作区,将导致 npm 仅在指定的工作区上运行,而不是在根项目上运行。

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.

描述

Description

对于任何可安装的东西(即包文件夹、tarball、tarball url、git url、name@tag、name@version、name 或 scoped name),此命令会将其提取到缓存中,将 tarball 复制到当前 工作目录为 <name>-<version>.tgz,然后将文件名写入标准输出。

For anything that's installable (that is, a package folder, tarball, tarball url, git url, name@tag, name@version, name, or scoped name), this command will fetch it to the cache, copy the tarball to the current working directory as <name>-<version>.tgz, and then write the filenames out to stdout.

如果多次指定同一个包,则该文件将被第二次覆盖。

If the same package is specified multiple times, then the file will be overwritten the second time.

如果未提供任何参数,则 npm 会打包当前的包文件夹。

If no arguments are supplied, then npm packs the current package folder.

也可以看看

See Also

npm 中文网 - 粤ICP备13048890号