1 ---
2 title: npm-pack
3 section: 1
4 description: Create a tarball from a package
5 github_repo: npm/cli
6 github_branch: release/v9
7 github_path: docs/lib/content/commands/npm-pack.md
8 redirect_from:
9 - /cli-documentation/v9/cli-commands/npm-pack
10 - /cli-documentation/v9/cli-commands/pack
11 - /cli-documentation/v9/commands/npm-pack
12 - /cli-documentation/v9/commands/pack
13 - /cli-documentation/v9/npm-pack
14 - /cli-documentation/v9/pack
15 - /cli/v9/cli-commands/npm-pack
16 - /cli/v9/cli-commands/pack
17 - /cli/v9/commands/pack
18 - /cli/v9/npm-pack
19 - /cli/v9/pack
20 ---
21
22 ### Synopsis
23
24 ```bash
25 npm pack <package-spec>
26 ```
27
28 ### Configuration
29
30 #### `dry-run`
31
32 - Default: false
33 - Type: Boolean
34
35 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`.
36
37 Note: This is NOT honored by other network related commands, eg `dist-tags`, `owner`, etc.
38
39 #### `json`
40
41 - Default: false
42 - Type: Boolean
43
44 Whether or not to output JSON data, rather than the normal output.
45
46 - In `npm pkg set` it enables parsing set values with JSON.parse() before saving them to your `package.json`.
47
48 Not supported by all npm commands.
49
50 #### `pack-destination`
51
52 - Default: "."
53 - Type: String
54
55 Directory in which `npm pack` will save tarballs.
56
57 #### `workspace`
58
59 - Default:
60 - Type: String (can be set multiple times)
61
62 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.
63
64 Valid values for the `workspace` config are either:
65
66 - Workspace names
67 - Path to a workspace directory
68 - Path to a parent workspace directory (will result in selecting all workspaces within that folder)
69
70 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.
71
72 This value is not exported to the environment for child processes.
73
74 #### `workspaces`
75
76 - Default: null
77 - Type: null or Boolean
78
79 Set to true to run the command in the context of **all** configured workspaces.
80
81 Explicitly setting this to false will cause commands like `install` to ignore workspaces altogether. When not set explicitly:
82
83 - 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.
84
85 This value is not exported to the environment for child processes.
86
87 #### `include-workspace-root`
88
89 - Default: false
90 - Type: Boolean
91
92 Include the workspace root when workspaces are enabled for a command.
93
94 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.
95
96 This value is not exported to the environment for child processes.
97
98 ### Description
99
100 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.
101
102 If the same package is specified multiple times, then the file will be overwritten the second time.
103
104 If no arguments are supplied, then npm packs the current package folder.
105
106 ### See Also
107
108 - [package spec](/cli/v9/using-npm/package-spec)
109 - [npm-packlist package](http://npm.im/npm-packlist)
110 - [npm cache](/cli/v9/commands/npm-cache)
111 - [npm publish](/cli/v9/commands/npm-publish)
112 - [npm config](/cli/v9/commands/npm-config)
113 - [npmrc](/cli/v9/configuring-npm/npmrc)