reggi/overrides
@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-hook |
| 3 | section: 1 |
| 4 | description: Manage registry hooks |
| 5 | github_repo: npm/cli |
| 6 | github_branch: latest |
| 7 | github_path: docs/lib/content/commands/npm-hook.md |
| 8 | redirect_from: |
| 9 | - /cli-commands/hook |
| 10 | - /cli-commands/npm-hook |
| 11 | - /cli-documentation/cli-commands/hook |
| 12 | - /cli-documentation/cli-commands/npm-hook |
| 13 | - /cli-documentation/commands/hook |
| 14 | - /cli-documentation/commands/npm-hook |
| 15 | - /cli-documentation/hook |
| 16 | - /cli-documentation/npm-hook |
| 17 | - /cli-documentation/v10/cli-commands/hook |
| 18 | - /cli-documentation/v10/cli-commands/npm-hook |
| 19 | - /cli-documentation/v10/commands/hook |
| 20 | - /cli-documentation/v10/commands/npm-hook |
| 21 | - /cli-documentation/v10/hook |
| 22 | - /cli-documentation/v10/npm-hook |
| 23 | - /cli/cli-commands/hook |
| 24 | - /cli/cli-commands/npm-hook |
| 25 | - /cli/commands/hook |
| 26 | - /cli/commands/npm-hook |
| 27 | - /cli/hook |
| 28 | - /cli/npm-hook |
| 29 | - /cli/v10/cli-commands/hook |
| 30 | - /cli/v10/cli-commands/npm-hook |
| 31 | - /cli/v10/commands/hook |
| 32 | - /cli/v10/hook |
| 33 | - /cli/v10/npm-hook |
| 34 | - /commands/hook |
| 35 | - /commands/npm-hook |
| 36 | --- |
| 37 | |
| 38 | ### Synopsis |
| 39 | |
| 40 | ```bash |
| 41 | npm hook add <pkg> <url> <secret> [--type=<type>] |
| 42 | npm hook ls [pkg] |
| 43 | npm hook rm <id> |
| 44 | npm hook update <id> <url> <secret> |
| 45 | ``` |
| 46 | |
| 47 | Note: This command is unaware of workspaces. |
| 48 | |
| 49 | ### Description |
| 50 | |
| 51 | Allows you to manage [npm hooks](https://blog.npmjs.org/post/145260155635/introducing-hooks-get-notifications-of-npm), including adding, removing, listing, and updating. |
| 52 | |
| 53 | Hooks allow you to configure URL endpoints that will be notified whenever a change happens to any of the supported entity types. Three different types of entities can be watched by hooks: packages, owners, and scopes. |
| 54 | |
| 55 | To create a package hook, simply reference the package name. |
| 56 | |
| 57 | To create an owner hook, prefix the owner name with `~` (as in, `~youruser`). |
| 58 | |
| 59 | To create a scope hook, prefix the scope name with `@` (as in, `@yourscope`). |
| 60 | |
| 61 | The hook `id` used by `update` and `rm` are the IDs listed in `npm hook ls` for that particular hook. |
| 62 | |
| 63 | The shared secret will be sent along to the URL endpoint so you can verify the request came from your own configured hook. |
| 64 | |
| 65 | ### Example |
| 66 | |
| 67 | Add a hook to watch a package for changes: |
| 68 | |
| 69 | ```bash |
| 70 | $ npm hook add lodash https://example.com/ my-shared-secret |
| 71 | ``` |
| 72 | |
| 73 | Add a hook to watch packages belonging to the user `substack`: |
| 74 | |
| 75 | ```bash |
| 76 | $ npm hook add ~substack https://example.com/ my-shared-secret |
| 77 | ``` |
| 78 | |
| 79 | Add a hook to watch packages in the scope `@npm` |
| 80 | |
| 81 | ```bash |
| 82 | $ npm hook add @npm https://example.com/ my-shared-secret |
| 83 | ``` |
| 84 | |
| 85 | List all your active hooks: |
| 86 | |
| 87 | ```bash |
| 88 | $ npm hook ls |
| 89 | ``` |
| 90 | |
| 91 | List your active hooks for the `lodash` package: |
| 92 | |
| 93 | ```bash |
| 94 | $ npm hook ls lodash |
| 95 | ``` |
| 96 | |
| 97 | Update an existing hook's url: |
| 98 | |
| 99 | ```bash |
| 100 | $ npm hook update id-deadbeef https://my-new-website.here/ |
| 101 | ``` |
| 102 | |
| 103 | Remove a hook: |
| 104 | |
| 105 | ```bash |
| 106 | $ npm hook rm id-deadbeef |
| 107 | ``` |
| 108 | |
| 109 | ### Configuration |
| 110 | |
| 111 | #### `registry` |
| 112 | |
| 113 | - Default: "https://registry.npmjs.org/" |
| 114 | - Type: URL |
| 115 | |
| 116 | The base URL of the npm registry. |
| 117 | |
| 118 | #### `otp` |
| 119 | |
| 120 | - Default: null |
| 121 | - Type: null or String |
| 122 | |
| 123 | This is a one-time password from a two-factor authenticator. It's needed when publishing or changing package permissions with `npm access`. |
| 124 | |
| 125 | If not set, and a registry response fails with a challenge for a one-time password, npm will prompt on the command line for one. |
| 126 | |
| 127 | ### See Also |
| 128 | |
| 129 | - ["Introducing Hooks" blog post](https://blog.npmjs.org/post/145260155635/introducing-hooks-get-notifications-of-npm) |