dependabot/npm_and_yarn/main/eslint-10.4.0
@reggi/path-to-regexp
dependabot/npm_and_yarn/main/copy-to-clipboard-4.0.2
dependabot/npm_and_yarn/main/eslint-10.4.0
dependabot/npm_and_yarn/main/npmcli/eslint-config-7.0.0
dependabot/npm_and_yarn/main/proc-log-7.0.0
dependabot/npm_and_yarn/npm_and_yarn-826852524d
dependabot/npm_and_yarn/npm_and_yarn-ab9a7f4bc2
deprecate-totp-2fa
dhei/classic-tokens
gat-bypass-2fa-docs
jpg619/fix-accessibility-content-flow
jpg619/version-bump-tar-2
kartykp/gat-bypass-2fa-docs
kartykp/upgrade-path-to-regex
main
maitxn/version-bump-tar
patch-1
reggi/cache-based-on-version
reggi/dev-engines
reggi/fix-transform-prettier
reggi/overrides
update-search-sensitivity
| 1 | --- |
| 2 | title: npm-set-script |
| 3 | section: 1 |
| 4 | description: Set tasks in the scripts section of package.json |
| 5 | github_repo: npm/cli |
| 6 | github_branch: release/v7 |
| 7 | github_path: docs/content/commands/npm-set-script.md |
| 8 | redirect_from: |
| 9 | - /cli-documentation/v7/cli-commands/npm-set-script |
| 10 | - /cli-documentation/v7/cli-commands/set-script |
| 11 | - /cli-documentation/v7/commands/npm-set-script |
| 12 | - /cli-documentation/v7/commands/set-script |
| 13 | - /cli-documentation/v7/npm-set-script |
| 14 | - /cli-documentation/v7/set-script |
| 15 | - /cli/v7/cli-commands/npm-set-script |
| 16 | - /cli/v7/cli-commands/set-script |
| 17 | - /cli/v7/commands/set-script |
| 18 | - /cli/v7/npm-set-script |
| 19 | - /cli/v7/set-script |
| 20 | --- |
| 21 | |
| 22 | ### Synopsis |
| 23 | |
| 24 | An npm command that lets you create a task in the `scripts` section of the `package.json`. |
| 25 | |
| 26 | ```bash |
| 27 | npm set-script [<script>] [<command>] |
| 28 | ``` |
| 29 | |
| 30 | **Example:** |
| 31 | |
| 32 | - `npm set-script start "http-server ."` |
| 33 | |
| 34 | ```json |
| 35 | { |
| 36 | "name": "my-project", |
| 37 | "scripts": { |
| 38 | "start": "http-server .", |
| 39 | "test": "some existing value" |
| 40 | } |
| 41 | } |
| 42 | ``` |
| 43 | |
| 44 | ### Configuration |
| 45 | |
| 46 | #### `workspace` |
| 47 | |
| 48 | - Default: |
| 49 | - Type: String (can be set multiple times) |
| 50 | |
| 51 | 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. |
| 52 | |
| 53 | Valid values for the `workspace` config are either: |
| 54 | |
| 55 | - Workspace names |
| 56 | - Path to a workspace directory |
| 57 | - Path to a parent workspace directory (will result to selecting all of the nested workspaces) |
| 58 | |
| 59 | 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. |
| 60 | |
| 61 | This value is not exported to the environment for child processes. |
| 62 | |
| 63 | #### `workspaces` |
| 64 | |
| 65 | - Default: false |
| 66 | - Type: Boolean |
| 67 | |
| 68 | Enable running a command in the context of **all** the configured workspaces. |
| 69 | |
| 70 | This value is not exported to the environment for child processes. |
| 71 | |
| 72 | ### See Also |
| 73 | |
| 74 | - [npm run-script](/cli/v7/commands/npm-run-script) |
| 75 | - [npm install](/cli/v7/commands/npm-install) |
| 76 | - [npm test](/cli/v7/commands/npm-test) |
| 77 | - [npm start](/cli/v7/commands/npm-start) |