1NPM-HOOK(1) NPM-HOOK(1)
2
3
4
6 npm-hook - Manage registry hooks
7
8 Synopsis
9 npm hook add <pkg> <url> <secret> [--type=<type>]
10 npm hook ls [pkg]
11 npm hook rm <id>
12 npm hook update <id> <url> <secret>
13
14 Note: This command is unaware of workspaces.
15
16 Description
17 Allows you to manage npm hooks
18 ⟨https://blog.npmjs.org/post/145260155635/introducing-hooks-get-notifi‐
19 cations-of-npm⟩, including adding, removing, listing, and updating.
20
21 Hooks allow you to configure URL endpoints that will be notified when‐
22 ever a change happens to any of the supported entity types. Three dif‐
23 ferent types of entities can be watched by hooks: packages, owners, and
24 scopes.
25
26 To create a package hook, simply reference the package name.
27
28 To create an owner hook, prefix the owner name with ~ (as in, ~you‐
29 ruser).
30
31 To create a scope hook, prefix the scope name with @ (as in,
32 @yourscope).
33
34 The hook id used by update and rm are the IDs listed in npm hook ls for
35 that particular hook.
36
37 The shared secret will be sent along to the URL endpoint so you can
38 verify the request came from your own configured hook.
39
40 Example
41 Add a hook to watch a package for changes:
42
43 $ npm hook add lodash https://example.com/ my-shared-secret
44
45 Add a hook to watch packages belonging to the user substack:
46
47 $ npm hook add ~substack https://example.com/ my-shared-secret
48
49 Add a hook to watch packages in the scope @npm
50
51 $ npm hook add @npm https://example.com/ my-shared-secret
52
53 List all your active hooks:
54
55 $ npm hook ls
56
57 List your active hooks for the lodash package:
58
59 $ npm hook ls lodash
60
61 Update an existing hook's url:
62
63 $ npm hook update id-deadbeef https://my-new-website.here/
64
65 Remove a hook:
66
67 $ npm hook rm id-deadbeef
68
69 Configuration
70 registry
71 • Default: "https://registry.npmjs.org/"
72
73 • Type: URL
74
75
76 The base URL of the npm registry.
77
78 otp
79 • Default: null
80
81 • Type: null or String
82
83
84 This is a one-time password from a two-factor authenticator. It's
85 needed when publishing or changing package permissions with npm access.
86
87 If not set, and a registry response fails with a challenge for a one-
88 time password, npm will prompt on the command line for one.
89
90 See Also
91 • "Introducing Hooks" blog post
92 ⟨https://blog.npmjs.org/post/145260155635/introducing-hooks-get-no‐
93 tifications-of-npm⟩
94
95
96
97 November 2023 NPM-HOOK(1)