11cb0ef41Sopenharmony_ci--- 21cb0ef41Sopenharmony_cititle: npm-pack 31cb0ef41Sopenharmony_cisection: 1 41cb0ef41Sopenharmony_cidescription: Create a tarball from a package 51cb0ef41Sopenharmony_ci--- 61cb0ef41Sopenharmony_ci 71cb0ef41Sopenharmony_ci### Synopsis 81cb0ef41Sopenharmony_ci 91cb0ef41Sopenharmony_ci```bash 101cb0ef41Sopenharmony_cinpm pack <package-spec> 111cb0ef41Sopenharmony_ci``` 121cb0ef41Sopenharmony_ci 131cb0ef41Sopenharmony_ci### Configuration 141cb0ef41Sopenharmony_ci 151cb0ef41Sopenharmony_ci#### `dry-run` 161cb0ef41Sopenharmony_ci 171cb0ef41Sopenharmony_ci* Default: false 181cb0ef41Sopenharmony_ci* Type: Boolean 191cb0ef41Sopenharmony_ci 201cb0ef41Sopenharmony_ciIndicates that you don't want npm to make any changes and that it should 211cb0ef41Sopenharmony_cionly report what it would have done. This can be passed into any of the 221cb0ef41Sopenharmony_cicommands that modify your local installation, eg, `install`, `update`, 231cb0ef41Sopenharmony_ci`dedupe`, `uninstall`, as well as `pack` and `publish`. 241cb0ef41Sopenharmony_ci 251cb0ef41Sopenharmony_ciNote: This is NOT honored by other network related commands, eg `dist-tags`, 261cb0ef41Sopenharmony_ci`owner`, etc. 271cb0ef41Sopenharmony_ci 281cb0ef41Sopenharmony_ci 291cb0ef41Sopenharmony_ci 301cb0ef41Sopenharmony_ci#### `json` 311cb0ef41Sopenharmony_ci 321cb0ef41Sopenharmony_ci* Default: false 331cb0ef41Sopenharmony_ci* Type: Boolean 341cb0ef41Sopenharmony_ci 351cb0ef41Sopenharmony_ciWhether or not to output JSON data, rather than the normal output. 361cb0ef41Sopenharmony_ci 371cb0ef41Sopenharmony_ci* In `npm pkg set` it enables parsing set values with JSON.parse() before 381cb0ef41Sopenharmony_ci saving them to your `package.json`. 391cb0ef41Sopenharmony_ci 401cb0ef41Sopenharmony_ciNot supported by all npm commands. 411cb0ef41Sopenharmony_ci 421cb0ef41Sopenharmony_ci 431cb0ef41Sopenharmony_ci 441cb0ef41Sopenharmony_ci#### `pack-destination` 451cb0ef41Sopenharmony_ci 461cb0ef41Sopenharmony_ci* Default: "." 471cb0ef41Sopenharmony_ci* Type: String 481cb0ef41Sopenharmony_ci 491cb0ef41Sopenharmony_ciDirectory in which `npm pack` will save tarballs. 501cb0ef41Sopenharmony_ci 511cb0ef41Sopenharmony_ci 521cb0ef41Sopenharmony_ci 531cb0ef41Sopenharmony_ci#### `workspace` 541cb0ef41Sopenharmony_ci 551cb0ef41Sopenharmony_ci* Default: 561cb0ef41Sopenharmony_ci* Type: String (can be set multiple times) 571cb0ef41Sopenharmony_ci 581cb0ef41Sopenharmony_ciEnable running a command in the context of the configured workspaces of the 591cb0ef41Sopenharmony_cicurrent project while filtering by running only the workspaces defined by 601cb0ef41Sopenharmony_cithis configuration option. 611cb0ef41Sopenharmony_ci 621cb0ef41Sopenharmony_ciValid values for the `workspace` config are either: 631cb0ef41Sopenharmony_ci 641cb0ef41Sopenharmony_ci* Workspace names 651cb0ef41Sopenharmony_ci* Path to a workspace directory 661cb0ef41Sopenharmony_ci* Path to a parent workspace directory (will result in selecting all 671cb0ef41Sopenharmony_ci workspaces within that folder) 681cb0ef41Sopenharmony_ci 691cb0ef41Sopenharmony_ciWhen set for the `npm init` command, this may be set to the folder of a 701cb0ef41Sopenharmony_ciworkspace which does not yet exist, to create the folder and set it up as a 711cb0ef41Sopenharmony_cibrand new workspace within the project. 721cb0ef41Sopenharmony_ci 731cb0ef41Sopenharmony_ciThis value is not exported to the environment for child processes. 741cb0ef41Sopenharmony_ci 751cb0ef41Sopenharmony_ci#### `workspaces` 761cb0ef41Sopenharmony_ci 771cb0ef41Sopenharmony_ci* Default: null 781cb0ef41Sopenharmony_ci* Type: null or Boolean 791cb0ef41Sopenharmony_ci 801cb0ef41Sopenharmony_ciSet to true to run the command in the context of **all** configured 811cb0ef41Sopenharmony_ciworkspaces. 821cb0ef41Sopenharmony_ci 831cb0ef41Sopenharmony_ciExplicitly setting this to false will cause commands like `install` to 841cb0ef41Sopenharmony_ciignore workspaces altogether. When not set explicitly: 851cb0ef41Sopenharmony_ci 861cb0ef41Sopenharmony_ci- Commands that operate on the `node_modules` tree (install, update, etc.) 871cb0ef41Sopenharmony_ciwill link workspaces into the `node_modules` folder. - Commands that do 881cb0ef41Sopenharmony_ciother things (test, exec, publish, etc.) will operate on the root project, 891cb0ef41Sopenharmony_ci_unless_ one or more workspaces are specified in the `workspace` config. 901cb0ef41Sopenharmony_ci 911cb0ef41Sopenharmony_ciThis value is not exported to the environment for child processes. 921cb0ef41Sopenharmony_ci 931cb0ef41Sopenharmony_ci#### `include-workspace-root` 941cb0ef41Sopenharmony_ci 951cb0ef41Sopenharmony_ci* Default: false 961cb0ef41Sopenharmony_ci* Type: Boolean 971cb0ef41Sopenharmony_ci 981cb0ef41Sopenharmony_ciInclude the workspace root when workspaces are enabled for a command. 991cb0ef41Sopenharmony_ci 1001cb0ef41Sopenharmony_ciWhen false, specifying individual workspaces via the `workspace` config, or 1011cb0ef41Sopenharmony_ciall workspaces via the `workspaces` flag, will cause npm to operate only on 1021cb0ef41Sopenharmony_cithe specified workspaces, and not on the root project. 1031cb0ef41Sopenharmony_ci 1041cb0ef41Sopenharmony_ciThis value is not exported to the environment for child processes. 1051cb0ef41Sopenharmony_ci 1061cb0ef41Sopenharmony_ci### Description 1071cb0ef41Sopenharmony_ci 1081cb0ef41Sopenharmony_ciFor anything that's installable (that is, a package folder, tarball, 1091cb0ef41Sopenharmony_citarball url, git url, name@tag, name@version, name, or scoped name), this 1101cb0ef41Sopenharmony_cicommand will fetch it to the cache, copy the tarball to the current working 1111cb0ef41Sopenharmony_cidirectory as `<name>-<version>.tgz`, and then write the filenames out to 1121cb0ef41Sopenharmony_cistdout. 1131cb0ef41Sopenharmony_ci 1141cb0ef41Sopenharmony_ciIf the same package is specified multiple times, then the file will be 1151cb0ef41Sopenharmony_cioverwritten the second time. 1161cb0ef41Sopenharmony_ci 1171cb0ef41Sopenharmony_ciIf no arguments are supplied, then npm packs the current package folder. 1181cb0ef41Sopenharmony_ci 1191cb0ef41Sopenharmony_ci### See Also 1201cb0ef41Sopenharmony_ci 1211cb0ef41Sopenharmony_ci* [package spec](/using-npm/package-spec) 1221cb0ef41Sopenharmony_ci* [npm-packlist package](http://npm.im/npm-packlist) 1231cb0ef41Sopenharmony_ci* [npm cache](/commands/npm-cache) 1241cb0ef41Sopenharmony_ci* [npm publish](/commands/npm-publish) 1251cb0ef41Sopenharmony_ci* [npm config](/commands/npm-config) 1261cb0ef41Sopenharmony_ci* [npmrc](/configuring-npm/npmrc) 127