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